ó +¢µRc@€sëddlmZddlZddlmZmZmZmZddlm Z m Z m Z m Z m Z ddlmZmZddlmZddlmZmZejeƒZdd„Zedd „ƒZddd „Zd „ZdS( iÿÿÿÿ(twith_statementN(tenvirontlistdirtremovetrmdir(tdirnametexiststjointgetsizetsplit(tPopentPIPE(t PUBLIC_DIR_RE(tmemoizetsitedirc C€slt|p gƒ}xS|D]K}t|dƒ4}x*|D]"}|r8|j|jƒƒq8q8WWdQXqW|S(s#Parse namespace_packages.txt files.trN(tsettopentaddtstrip(tfpathstothertresulttfpathtfptline((s(/usr/share/python/debpython/namespace.pytparse"s  $cC€sµd}dtjddƒ}|rLt||ƒ}t|ƒrƒ|g}qƒn7t|ƒrƒgt|ƒD]}t||ƒ^qe}n|r¨td„t|ƒDƒƒ}n tƒ}|S(s~Return a set of namespaces to regenerate/clean. :param package: limit namespaces to the ones needed by given package s%s/usr/share/python/ns/tDESTDIRtcs€s!|]}|jddƒVqdS(t.t/N(treplace(t.0ti((s(/usr/share/python/debpython/namespace.pys AsN(tNoneRtgetRRRRR(tpackageRtnsdirRR!R((s(/usr/share/python/debpython/namespace.pytload-s  + cc€sU|d k r-t|ƒ}tƒ}tƒ}nx/|D]'}|V|d krQq4nt|ƒ}||kr4|j|ƒtj|ƒ}|r[|jƒ} x¾|| krT|t| ƒd} | |kr4t |dƒ} |t kr$yt | dƒj ƒWn!t k rtjd| ƒq1X| Vq4|j| ƒn|j|ƒt|ƒd}qšWq[q4q4W|tkrQ|rQtddj |ƒdt d tƒ} | jƒ\} }xF| jƒD]8}|jd dƒd}||krµ|j|ƒqµqµWx]|D]R} yt| ƒWn6ttfk rD}tjd | ƒtj|ƒqøX| VqøWnd S( s)Add __init__.py files to given generator.is __init__.pytascannot create %sis/usr/bin/dpkg -S %s 2>/dev/nullt tshelltstdouts: scannot remove %sN(R"R&RRRR tmatchtgrouptlenRtTrueRtcloset ExceptiontlogterrorR tFalseR R t communicatet splitlinesRtIOErrortOSErrortdebug(tfilesR$tactiont namespacestalready_processedtremoval_candidatestfntdpathtmt public_dirtns_dirRtprocessR*tstderrRtnste((s(/usr/share/python/debpython/namespace.pytadd_namespace_filesGsT                c C€s¯t|tƒst|ƒ}ntƒ}x”|D]Œ}xƒ|D]{}tt||ƒ|jdƒŒ}t|dƒ}t|ƒsƒq;nt|ƒdkr;tjd|ƒ|j |ƒPq;q;Wq.W||}xà|D]Ø}xp|D]h}tt||ƒ|jdƒŒ}t|dƒ}t|ƒrÜt |ƒt |ƒsDt |ƒqDqÜqÜWtd|d|jdƒŒ}t|dƒ}t|ƒrÏt |ƒt |ƒs§t |ƒq§qÏqÏW|S(s8Remove empty __init__.py files for requested namespaces.Rs __init__.pyis)file not empty, cannot share %s namespacetdebiansusr/share/pyshared( t isinstanceRRRR RRR1twarningRRRR( R$R;tversionstkeepREtversionRRR?((s(/usr/share/python/debpython/namespace.pytremove_from_packages:   !      !      (t __future__RtloggingtosRRRRtos.pathRRRRR t subprocessR R tdebpython.pydistR tdebpython.toolsR Rt getLoggert__name__R1R"RR&RGRN(((s(/usr/share/python/debpython/namespace.pyts "( 8