ó
Nä²Wc           @@  sý  d  d l  m Z y d  d l m Z Wn e k
 r= e Z n Xd  d l Z d  d l Z d  d l Z d  d l	 Z	 d  d l
 Z
 d  d l Z d  d l m Z e j j Z d „  Z d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z e e e d „ ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z d „  Z e j  d ƒ j! Z" d „  Z# d „  Z$ d „  Z% d d d d „ Z' d d d „ Z( d „  Z) d „  Z* e d „  ƒ Z+ e d d d „ ƒ Z, d e j- e. d  „ Z/ d! d$ d" „  ƒ  YZ0 d# „  Z1 d S(%   i    (   t   absolute_import(   t
   basestringN(   t   contextmanagerc         @  s1   i  ‰  t  ƒ  ‰ ‡  ‡ ‡ f d †  } ˆ | _ | S(   Nc          @  s9   ˆ  j  |  ˆ ƒ } | ˆ k r5 ˆ |  Œ  } ˆ  |  <n  | S(   N(   t   get(   t   argst   res(   t   cachet   ft
   uncomputed(    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   wrapper   s    (   t   objectt   uncached(   R   R	   (    (   R   R   R   s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   cached_function   s
    		c         @  s#   d ˆ j  ‰  ‡  ‡ f d †  } | S(   Ns
   __%s_cachec         @  sf   t  |  ˆ  d  ƒ } | d  k r7 i  } t |  ˆ  | ƒ n  | | k rK | | Sˆ |  | Œ } | | <| S(   N(   t   getattrt   Nonet   setattr(   t   selfR   R   R   (   t
   cache_nameR   (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyR	   %   s    (   t   __name__(   R   R	   (    (   R   R   s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   cached_method#   s    	c         C@  s    t  j j |  ƒ \ } } | | S(   N(   t   ost   patht   splitext(   R   t   newsuft   baset   _(    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   replace_suffix0   s    c         C@  s8   t  j j |  ƒ r" t  j |  ƒ n  t j |  d d d ƒS(   Nt   wt   encodings
   ISO-8859-1(   R   R   t   existst   unlinkt   codecst   open(   R   (    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   open_new_file5   s    c         C@  sh   y t  |  ƒ } Wn t k
 r# nA X| j d ƒ | j ƒ  | rd t j |  | j | j d f ƒ n  d  S(   NsN   #error Do not use this file, it is the result of a failed Cython compilation.
i   (   R!   t   EnvironmentErrort   writet   closeR   t   utimet   st_atimet   st_mtime(   R   t   stR   (    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   castrate_fileD   s    
c         C@  s   t  |  ƒ } | | k S(   N(   t   modification_time(   R   t   timet   ftime(    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   file_newer_thanT   s    c         C@  sA   y t  j |  ƒ Wn) t k
 r< t  j j |  ƒ s= ‚  q= n Xd  S(   N(   R   t   makedirst   OSErrorR   t   isdir(   R   (    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   safe_makedirsY   s
    c         C@  sv   t  j j | t  j j |  ƒ ƒ } y t | ƒ } Wn t k
 rN t | ƒ n Xt |  | ƒ sb d St j	 |  | ƒ d S(   sÇ   
    Copy file sourcefile to directory destdir (creating it if needed),
    preserving metadata. If the destination file exists and is not
    older than the source file, the copying is skipped.
    N(
   R   R   t   joint   basenameR*   R/   R1   R-   t   shutilt   copy2(   t
   sourcefilet   destdirt   destfilet   desttime(    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   copy_file_to_dir_if_newera   s    !c         C@  s¨  | r |  t  t j ƒ }  n  | r˜ | d } d d l m } t | | ƒ sZ t d ƒ ‚ n  | r t j j | j	 ƒ f |  }  q˜ t
 | j	 ƒ f |  }  n  | } | r± | | 7} n  | s÷ | j d ƒ }	 t  |	 d  ƒ }
 |	 d } | | } d | } n  xª |  D]¢ } t j j | | ƒ } t | ƒ r)| S| sþ t | |
 ƒ } | d  k	 r t j j | | ƒ } t | ƒ ro| St j j | | | | ƒ } t | ƒ r| Sq qþ qþ Wd  S(   Ni    (   t   FileSourceDescriptors$   Only file sources for code supportedt   .iÿÿÿÿt   __init__(   t   tuplet   sysR   t   Cython.Compiler.ScanningR;   t
   isinstancet   RuntimeErrorR   t   dirnamet   filenamet   find_root_package_dirt   splitR2   t   path_existst   check_package_dirR   (   t   dirst   qualified_namet   suffixt   post   includet   sys_patht	   file_descR;   t   dotted_filenamet   namest   package_namest   module_namet   module_filenamet   package_filenamet   dirR   t   package_dir(    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   search_include_directoriest   sD    	


	c         C@  s@   t  j j |  ƒ } |  | k r" | St | ƒ r8 t | ƒ S| Sd  S(   N(   R   R   RC   t   is_package_dirRE   (   t	   file_pathRV   (    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyRE   ¤   s    
c         C@  s:   x3 | D]+ } t  j j |  | ƒ }  t |  ƒ s d  Sq W|  S(   N(   R   R   R2   RY   R   (   RV   RR   RC   (    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyRH   ®   s
    c         C@  s:   x3 d D]+ } t  j j |  | ƒ } t | ƒ r d Sq Wd  S(   Ns   __init__.pys   __init__.pycs   __init__.pyxs   __init__.pxdi   (   s   __init__.pys   __init__.pycs   __init__.pyxs   __init__.pxd(   R   R   R2   RG   (   t   dir_pathRD   R   (    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyRY   ¶   s      
c         C@  sµ   t  j j |  ƒ r t Sy‡ t } t | d d  ƒ } | rœ t  j j |  ƒ } | j | ƒ rœ | t	 | ƒ d } y | j
 | ƒ t SWq™ t k
 r• t SXqœ n  Wn t k
 r° n Xt S(   Nt   archivei   (   R   R   R   t   Truet
   __loader__R   R   t   normpatht
   startswitht   lent   get_datat   IOErrort   Falset	   NameError(   R   t   loadert   archive_pathR_   t   arcname(    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyRG   À   s"    c         C@  sd   t  |  t ƒ r` y: t j ƒ  } | d  k r9 t j ƒ  } n  |  j | ƒ }  Wq` t k
 r\ q` Xn  |  S(   N(   RA   t   bytesR?   t   getfilesystemencodingR   t   getdefaultencodingt   decodet   UnicodeDecodeError(   RD   t   filename_encoding(    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   decode_filenameÚ   s    u   coding[:=]\s*([-\w.]+)c         C@  s8   t  |  d d d d ƒ} z t | ƒ SWd  | j ƒ  Xd  S(   NR   s   UTF-8t   error_handlingt   ignore(   t   open_source_filet   detect_opened_file_encodingR$   (   t   source_filenameR   (    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   detect_file_encodingê   s    c         C@  s&  |  j  d ƒ j d ƒ } t | ƒ d k rŒ t | d ƒ } | rM | j d ƒ St | ƒ d k rŒ t | d ƒ } | r‚ | j d ƒ Sd SqŒ n  |  j d ƒ g  } x€ t d ƒ D]r } |  j  d ƒ } x2 | rõ | d k rõ | j | ƒ |  j  d ƒ } qÄ Wt d j | ƒ ƒ } | r¬ | j d ƒ Sq¬ Wd S(   Niú   u   
i   i    i   s   UTF-8u    (	   t   readRF   Ra   t   _match_file_encodingt   groupt   seekt   ranget   appendR2   (   R   t   linest   mt   charst   it   cR   (    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyRs   ò   s*    
c         C@  s)   |  j  d ƒ d k r% |  j d ƒ n  d S(   s¢   
    Read past a BOM at the beginning of a source file.
    This could be added to the scanner, but it's *substantially* easier
    to keep it at this level.
    i   u   ï»¿i    N(   Rv   Ry   (   R   (    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   skip_bom  s    t   rc         C@  s  | d  k rv t |  d d d | d d ƒ} t | ƒ } | d k ri | d k ri | j d ƒ t | ƒ | S| j ƒ  n  t j j |  ƒ sÔ y/ t	 } |  j
 | j ƒ r¶ t | |  | | ƒ SWqÔ t t f k
 rÐ qÔ Xn  t j |  d | d | d | ƒ} t | ƒ | S(   NR   s   UTF-8t   modeRp   Rq   i    t   errors(   R   Rr   Rs   Ry   R   R$   R   R   R   R^   R`   R\   t   open_source_from_loaderRe   t   AttributeErrort   ioR    (   Rt   Rƒ   R   Rp   R   Rf   t   stream(    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyRr     s*    

c         C@  sZ   t  j j | ƒ } | t |  j ƒ d } |  j | ƒ } t j t j | ƒ d | d | ƒS(   Ni   R   R„   (	   R   R   R_   Ra   R\   Rb   R‡   t   TextIOWrappert   BytesIO(   Rf   Rt   R   Rp   t   nrmpathRh   t   data(    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyR…   7  s    c         C@  sý   t  } |  d  d k r) t } |  d }  n  t |  ƒ d k  rM t |  d ƒ }  n¡ |  d d k rß |  d } | d k r‰ t |  d d ƒ }  qî | d k r« t |  d d	 ƒ }  qî | d
 k rÍ t |  d d ƒ }  qî t |  d	 ƒ }  n t |  d ƒ }  | rù |  S|  S(   Ni   t   -i   i    t   0t   xXi   t   oOi   t   bB(   Rd   R]   Ra   t   int(   t   valuet   is_negt   literal_type(    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   str_to_numberB  s"    
c         C@  s9   t  |  t ƒ r t |  ƒ }  n  d |  k o5 d k  n S(   Ni   i   I   €    i   €I   €    (   RA   R   R–   (   R“   (    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   long_literal^  s    c          C@  s²   d t  j k r t  j d Sd	 }  t  j d k rh t j d k rS t  j j d ƒ }  qh t  j j d ƒ }  n  |  r“ t  j j	 |  ƒ r“ t  j j
 |  d ƒ St  j j t  j j
 d d ƒ ƒ S(
   sÇ   get the cython cache dir

    Priority:

    1. CYTHON_CACHE_DIR
    2. (OS X): ~/Library/Caches/Cython
       (posix not OS X): XDG_CACHE_HOME/cython if XDG_CACHE_HOME defined
    3. ~/.cython

    t   CYTHON_CACHE_DIRt   posixt   darwins   ~/Library/Cachest   XDG_CACHE_HOMEt   cythont   ~s   .cythonN(   R   t   environR   t   nameR?   t   platformR   t
   expanduserR   R0   R2   (   t   parent(    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   get_cython_cache_dird  s    i   c         #@  só   d  ‰ } t j |  ƒ } zÅ t j ƒ  \ ‰ } t j | |  ƒ zr t j | ƒ g  ‰  ‡  ‡ f d †  } ‡  ‡ f d †  } d d l m } | d | ƒ } t | _	 | j
 ƒ  | VWd  t j | |  ƒ | d  k	 rÜ | j ƒ  n  XWd  t j | ƒ Xd  S(   Nc          @  sO   z: x3 t  r8 t j ˆ d ƒ }  |  r4 ˆ  j |  ƒ q Pq WWd  t j ˆ ƒ Xd  S(   Niè  (   R]   R   Rv   R{   R$   (   t   d(   RŒ   t   pipe_in(    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   copy  s    		c          @  s+   d j  ˆ  ƒ }  ˆ r' |  j ˆ ƒ }  n  |  S(   Nt    (   R2   Rl   (   t   output(   RŒ   R   (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt
   get_output˜  s    i    (   t   Threadt   target(   R   R   t   dupt   pipet   dup2R$   t	   threadingRª   R]   t   daemont   startR2   (   Rˆ   R   t   tt   orig_streamt   pipe_outR¦   R©   Rª   (    (   RŒ   R   R¥   s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   captured_fd‚  s&    
	
	s   
c         C@  sk   | j  ƒ  y | j } Wn t k
 r0 | } n X| j |  ƒ | rT | j | ƒ n  | rg | j  ƒ  n  d  S(   N(   t   flusht   bufferR†   R#   (   t   st   endt   fileR¶   t   out(    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   print_bytes«  s    

t   LazyStrc           B@  s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C@  s   | |  _  d  S(   N(   t   callback(   R   R¾   (    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyR=   ¸  s    c         C@  s
   |  j  ƒ  S(   N(   R¾   (   R   (    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   __str__º  s    c         C@  s
   |  j  ƒ  S(   N(   R¾   (   R   (    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   __repr__¼  s    c         C@  s   |  j  ƒ  | S(   N(   R¾   (   R   t   right(    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   __add__¾  s    c         C@  s   | |  j  ƒ  S(   N(   R¾   (   R   t   left(    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   __radd__À  s    (   R   t
   __module__R=   R¿   RÀ   RÂ   RÄ   (    (    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyR½   ·  s
   				c         @  s   ‡  f d †  } | S(   s6   Class decorator for creating a class with a metaclass.c         @  sœ   |  j  j ƒ  } | j d ƒ } | d  k	 rf t | t ƒ rE | g } n  x | D] } | j | ƒ qL Wn  | j d d  ƒ | j d d  ƒ ˆ  |  j |  j | ƒ S(   Nt	   __slots__t   __dict__t   __weakref__(	   RÇ   R¦   R   R   RA   t   strt   popR   t	   __bases__(   t   clst	   orig_varst   slotst	   slots_var(   t	   metaclass(    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyR	   È  s    (    (   RÐ   R	   (    (   RÐ   s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   add_metaclassÆ  s    (    (2   t
   __future__R    t   __builtin__R   t   ImportErrorRÉ   R   R?   t   reR‡   R   R4   t
   contextlibR   R   t   getmtimeR*   R   R   R   R!   R)   R-   R1   R:   Rd   RX   RE   RH   RY   RG   Ro   t   compilet   searchRw   Ru   Rs   R   R   Rr   R…   R–   R—   R£   Rµ   t   stdoutR]   R¼   R½   RÑ   (    (    (    s/   /bar/jli/Chip-seq/script/cython/Cython/Utils.pyt   <module>   sT   
								.

				
			(