o 年f- @sddlZddlmZmZddlmZmZmZddlm Z m Z ddl m Z e eZdddZdd d Zd d Zd dZddZdS)N)walkenviron)abspathisfilejoin)PopenPIPE) PUBLIC_DIR_REz.pyccst|}t|ttfr|D] }t|D]}|VqqdSt|r+||r+|VdStt|D]\}}}|D] }||rEt||Vq8q1dS)z6Generate *.py file names available in given directory.N) tuple isinstancelistfrom_directoryrendswithrrr)dname extensionsitemfnrootdirs file_namesr%/usr/share/python3/debpython/files.pyrs"    rccst|}t}d|d<tdd|ftt|d}|\}}|jdkr)td||jdd d }| D] }| |r>|Vq4d S) z4Generate *.py file names available in given package.zC.UTF-8LC_ALLz /usr/bin/dpkgz-L)stdoutstderrenvrzcannot get content of %szutf-8replace)errorsN) r rcopyrr communicate returncode Exceptiondecode splitlinesr) package_namerrprocessrrlinerrr from_package.s       r(ccs |D] }||r |VqdS)z4Generate *.py file names that match given directory.N) startswith)filesrrrrrfilter_directory>s  r+ccsbtdd|D}tdd|D}|D]}t|}|r.|d}||vs+||vr.|VqdS)z3Generate *.py file names that match given versions.css|]}d|VqdS)z%d.%dNr.0irrr Gsz filter_public..css|] }t|dVqdS)rN)strr,rrrr/HsN)setr matchgroup)r*versionsvstr shared_vstrr public_dirversrrr filter_publicEs  r:ccs(t|}|D] }||s|VqdS)zs