
    9bh>                         S SK r S SKJrJr  S SKJrJrJr  S SKJ	r	J
r
  S SKJr  \ R                  " \5      rSS jrSS jrS rS	 rS
 rg)    N)environwalk)abspathisfilejoin)PopenPIPE)PUBLIC_DIR_REc              #     #    [        U5      n[        U [        [         45      (       a   U  H  n[        X!5       H  nUv   M	     M     g[	        U 5      (       a  U R                  U5      (       a  U v   g[        [        U 5      5       H4  u  pEnU H(  nUR                  U5      (       d  M  [        XC5      v   M*     M6     g7f)z6Generate *.py file names available in given directory.N)	tuple
isinstancelistfrom_directoryr   endswithr   r   r   )dname
extensionsitemfnrootdirs
file_namess          %/usr/share/python3/debpython/files.pyr   r      s     z"J%$''D$T6 7  
5>>*55&*75>&:"D
 ;;z**t.( ! ';s   B%C+Cc              #   j  #    [        U5      n[        R                  " 5       nSUS'   [        SSU 4[        [        US9nUR                  5       u  pEUR                  S:w  a  [        SU -  5      eUR                  SS	S
9nUR                  5        H  nUR                  U5      (       d  M  Uv   M!     g7f)z4Generate *.py file names available in given package.zC.UTF-8LC_ALLz/usr/bin/dpkgz-L)stdoutstderrenvr   zcannot get content of %szutf-8replace)errorsN)r   r   copyr   r	   communicate
returncode	Exceptiondecode
splitlinesr   )package_namer   r   processr   r   lines          r   from_packager)   .   s     z"J
,,.CCM_dL9$ $#/G((*NFQ2\ABB]]79]5F!!#==$$J $s   B$B3*	B3c              #   V   #    U  H  nUR                  U5      (       d  M  Uv   M!     g7f)z4Generate *.py file names that match given directory.N)
startswith)filesr   r   s      r   filter_directoryr-   >   s#     ==H s   )	)c              #      #    [        S U 5       5      n[        S U 5       5      nU  HC  n[        R                  " U5      nU(       d  M"  UR                  S5      nXc;   d  Xb;   d  M?  Uv   ME     g7f)z3Generate *.py file names that match given versions.c              3   ,   #    U  H
  nS U-  v   M     g7f)z%d.%dN .0is     r   	<genexpr> filter_public.<locals>.<genexpr>G   s     -Hqw{Hs   c              3   >   #    U  H  n[        US    5      v   M     g7f)r   N)strr1   s     r   r4   r5   H   s     2Ac!A$iis      N)setr
   matchgroup)r,   versionsvstrshared_vstrr   
public_dirverss          r   filter_publicrA   E   sc     -H--D222K"((,
:##A&D"dl s   AA1A1(	A1c              #   l   #    [        U5      nU  H  nUR                  U5      (       a  M  Uv   M!     g7f)z<Removes files with matching extensions from given generator.N)r   r   )r,   r   r   s      r   filter_out_extrC   Q   s-     z"J{{:&&H s   %4	4))z.py)loggingosr   r   os.pathr   r   r   
subprocessr   r	   	debpythonr
   	getLogger__name__logr   r)   r-   rA   rC   r0       r   <module>rM      sB   *   ) ) " #!)  	rL   