й¼]æ0ã@s¼ddlZddlZddlZddlZddlmZddlmZmZddl m Z Gdd„dƒZ dd„Z ej d d „Zd d „Zd dddd„ZdS)éN)Ú convert_path)ÚDistutilsTemplateErrorÚDistutilsInternalError)Úlogc@s¾eZdZdddd„Zdd„Zejdd„Zdd „Zd d „Z d d „Z dd„Z dd„Z dd„Z dd„Zddddd„Zddddd„ZdS)ÚFileListNcCsd|_g|_dS)N)ÚallfilesÚfiles)ÚselfÚwarnÚ debug_print©r ú-/opt/alt/python35/lib64/python3.5/filelist.pyÚ__init__s zFileList.__init__cCs ||_dS)N)r)r rr r r Ú set_allfiles#szFileList.set_allfilescCst|ƒ|_dS)N)Úfindallr)r Údirr r r r&szFileList.findallcCs$ddlm}|r t|ƒdS)Nr)ÚDEBUG)Zdistutils.debugrÚprint)r Úmsgrr r r r )szFileList.debug_printcCs|jj|ƒdS)N)rÚappend)r Úitemr r r r3szFileList.appendcCs|jj|ƒdS)N)rÚextend)r Úitemsr r r r6szFileList.extendcCsXtttjj|jƒƒ}g|_x*|D]"}|jjtjj|Œƒq.WdS)N)ÚsortedÚmapÚosÚpathÚsplitrrÚjoin)r Zsortable_filesZ sort_tupler r r Úsort9s  z FileList.sortcCsVxOtt|jƒdddƒD].}|j||j|dkr |j|=q WdS)Néréÿÿÿÿ)ÚrangeÚlenr)r Úir r r Úremove_duplicatesCs&zFileList.remove_duplicatescCs1|jƒ}|d}d}}}|dkrrt|ƒdkrRtd|ƒ‚dd „|d d…Dƒ}n¯|dkrÐt|ƒd kr td|ƒ‚t|d ƒ}dd „|dd…Dƒ}nQ|dkrt|ƒdkrþtd|ƒ‚t|d ƒ}ntd|ƒ‚||||fS)NrÚincludeÚexcludeúglobal-includeúglobal-excludeéz&'%s' expects ...cSsg|]}t|ƒ‘qSr )r)Ú.0Úwr r r ú Ws z1FileList._parse_template_line..r úrecursive-includeúrecursive-excludeéz,'%s' expects ...cSsg|]}t|ƒ‘qSr )r)r+r,r r r r-]s ÚgraftÚprunez#'%s' expects a single zunknown action '%s')r&r'r(r))r.r/)r1r2)rr#rr)r ÚlineZwordsÚactionÚpatternsrÚ dir_patternr r r Ú_parse_template_lineLs,          zFileList._parse_template_linecCs|j|ƒ\}}}}|dkrz|jddj|ƒƒx½|D]+}|j|ddƒsHtjd|ƒqHWn‡|dkrÙ|jddj|ƒƒx^|D]+}|j|ddƒs§tjd |ƒq§Wn(|d kr8|jd dj|ƒƒxÿ|D]+}|j|dd ƒstjd |ƒqWnÉ|dkr—|jddj|ƒƒx |D]+}|j|dd ƒsetjd|ƒqeWnj|dkrÿ|jd|dj|ƒfƒx;|D].}|j|d|ƒsÊtjd||ƒqÊWn|dkrg|jd|dj|ƒfƒxÓ|D].}|j|d|ƒs2tjd||ƒq2Wnš|dkr¬|jd|ƒ|jdd|ƒstjd|ƒnU|dkrñ|jd|ƒ|jdd|ƒstjd|ƒntd|ƒ‚dS)Nr&zinclude ú Úanchorr z%warning: no files found matching '%s'r'zexclude z9warning: no previously-included files found matching '%s'zglobal-includezglobal-include rz>warning: no files found matching '%s' anywhere in distributionzglobal-excludezglobal-exclude zRwarning: no previously-included files matching '%s' found anywhere in distributionzrecursive-includezrecursive-include %s %sÚprefixz:warning: no files found matching '%s' under directory '%s'zrecursive-excludezrecursive-exclude %s %szNwarning: no previously-included files matching '%s' found under directory '%s'r1zgraft z+warning: no directories found matching '%s'r2zprune z6no previously-included directories found matching '%s'z'this cannot happen: invalid action '%s')r7r rÚinclude_patternrr Úexclude_patternr)r r3r4r5rr6Úpatternr r r Úprocess_template_linehsf                          zFileList.process_template_liner rcCs–d}t||||ƒ}|jd|jƒ|jdkrH|jƒxG|jD]<}|j|ƒrR|jd|ƒ|jj|ƒd}qRW|S)NFz%include_pattern: applying regex r'%s'z adding T)Útranslate_patternr r=rrÚsearchrr)r r=r9r:Úis_regexÚ files_foundÚ pattern_reÚnamer r r r;´s    zFileList.include_patterncCs›d}t||||ƒ}|jd|jƒxett|jƒdddƒD]D}|j|j|ƒrO|jd|j|ƒ|j|=d}qOW|S)NFz%exclude_pattern: applying regex r'%s'r z removing Tr!r!)r?r r=r"r#rr@)r r=r9r:rArBrCr$r r r r<ßs  &  zFileList.exclude_pattern)Ú__name__Ú __module__Ú __qualname__rrrÚcurdirrr rrrr%r7r>r;r<r r r r rs      L,rcCs5dd„tj|ddƒDƒ}ttjj|ƒS)Ncss:|]0\}}}|D]}tjj||ƒVqqdS)N)rrr)r+ÚbaseÚdirsrÚfiler r r ú ûs z#_find_all_simple..Ú followlinksT)rÚwalkÚfilterrÚisfile)rÚresultsr r r Ú_find_all_simpleös rRcCsOt|ƒ}|tjkrEtjtjjd|ƒ}t||ƒ}t|ƒS)NÚstart) rRrrHÚ functoolsÚpartialrÚrelpathrÚlist)rrZmake_relr r r rs  rcCsPtj|ƒ}tj}tjdkr-d}d|}tjd||ƒ}|S)Nú\z\\\\z\1[^%s]z((?s  è