ó
8Nc           @   s”   d  d l  Z  d  d l m Z d  d l m Z m Z m Z d  d l m Z m	 Z	 e  j
 e ƒ Z d d „ Z d d „ Z d „  Z d	 „  Z d
 „  Z d S(   iÿÿÿÿN(   t   walk(   t   abspatht   isfilet   join(   t   Popent   PIPEs   .pyc         c   sÏ   t  | ƒ } t |  t t  f ƒ rQ x§ |  D]" } x t | ƒ D] } | Vq; Wq( Wnz t |  ƒ rt |  j | ƒ rt |  VnW xT t t |  ƒ ƒ D]@ \ } } } x. | D]& } | j | ƒ r t | | ƒ Vq q Wq‡ Wd S(   s6   Generate *.py file names available in given directory.N(	   t   tuplet
   isinstancet   listt   from_directoryR   t   endswithR    R   R   (   t   dnamet
   extensionst   itemt   fnt   roott   dirst
   file_names(    (    s$   /usr/share/python/debpython/files.pyR	      s    "c         c   sŽ   t  | ƒ } t d |  d t d t ƒ} | j ƒ  \ } } | j d k r\ t d |  ƒ ‚ n  x+ | j ƒ  D] } | j | ƒ ri | Vqi qi Wd S(   s4   Generate *.py file names available in given package.s   /usr/bin/dpkg -L %st   shellt   stdouti    s   cannot get content of %sN(	   R   R   t   TrueR   t   communicatet
   returncodet	   Exceptiont
   splitlinesR
   (   t   package_nameR   t   processR   t   stderrt   line(    (    s$   /usr/share/python/debpython/files.pyt   from_package.   s    c         c   s,   x% |  D] } | j  | ƒ r | Vq q Wd S(   s4   Generate *.py file names that match given directory.N(   t
   startswith(   t   filesR   R   (    (    s$   /usr/share/python/debpython/files.pyt   filter_directory;   s    c         c   sU   t  d „  | Dƒ ƒ } x8 |  D]0 } | j d ƒ r | d d !| k r | Vq q Wd S(   s3   Generate *.py file names that match given versions.c         s   s   |  ] } d  | Vq d S(   s   %d.%dN(    (   t   .0t   i(    (    s$   /usr/share/python/debpython/files.pys	   <genexpr>D   s    s   /usr/lib/pythoni   i   N(   t   setR   (   R   t   versionst   versions_strR   (    (    s$   /usr/share/python/debpython/files.pyt   filter_publicB   s
    c         c   s,   x% |  D] } | j  | ƒ s | Vq q Wd S(   s<   Removes files with matching extensions from given generator.N(   R
   (   R   R   R   (    (    s$   /usr/share/python/debpython/files.pyt   filter_out_extK   s    (   s   .py(   s   .py(   t   loggingt   osR    t   os.pathR   R   R   t
   subprocessR   R   t	   getLoggert   __name__t   logR	   R   R    R&   R'   (    (    (    s$   /usr/share/python/debpython/files.pyt   <module>   s   			