3 \ 2ã@s†dZddlZddlZddlZddlZddlmZddlmZm Z ddl m Z Gdd„dƒZ dd „Z ejfd d „Zd d „Zddd„ZdS)zsdistutils.filelist Provides the FileList class, used for poking about the filesystem and building lists of files. éN)Ú convert_path)ÚDistutilsTemplateErrorÚDistutilsInternalError)Úlogc@s|eZdZdZddd„Zdd„Zejfdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z dd„Zdd„Zddd„Zddd„ZdS) ÚFileListaÑA list of files built by on exploring the filesystem and filtered by applying various patterns to what we find there. Instance attributes: dir directory from which files will be taken -- only used if 'allfiles' not supplied to constructor files list of filenames currently being built/filtered/manipulated allfiles complete list of files under consideration (ie. without any filtering applied) NcCsd|_g|_dS)N)ÚallfilesÚfiles)ÚselfÚwarnÚ debug_print©r ú*/usr/lib64/python3.6/distutils/filelist.pyÚ__init__szFileList.__init__cCs ||_dS)N)r)r rr r r Ú set_allfiles#szFileList.set_allfilescCst|ƒ|_dS)N)Úfindallr)r Údirr r r r&szFileList.findallcCsddlm}|rt|ƒdS)z~Print 'msg' to stdout if the global DEBUG (taken from the DISTUTILS_DEBUG environment variable) flag is true. r)ÚDEBUGN)Zdistutils.debugrÚprint)r Úmsgrr r r r )s zFileList.debug_printcCs|jj|ƒdS)N)rÚappend)r Úitemr r r r3szFileList.appendcCs|jj|ƒdS)N)rÚextend)r Úitemsr r r r6szFileList.extendcCs@tttjj|jƒƒ}g|_x |D]}|jjtjj|Žƒq WdS)N)ÚsortedÚmapÚosÚpathÚsplitrrÚjoin)r Zsortable_filesZ sort_tupler r r Úsort9s z FileList.sortcCsDx>tt|jƒdddƒD]$}|j||j|dkr|j|=qWdS)Néréÿÿÿÿ)ÚrangeÚlenr)r Úir r r Úremove_duplicatesCszFileList.remove_duplicatescCsÞ|jƒ}|d}d}}}|dkrTt|ƒdkr ...cSsg|] }t|ƒ‘qSr )r)Ú.0Úwr r r ú Wsz1FileList._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_linecCsX|j|ƒ\}}}}|dkrZ|jddj|ƒƒx&|D]}|j|dd�s4tjd|ƒq4W�nú|dkr¢|jddj|ƒƒx&|D]}|j|dd�s|tjd |ƒq|W�n²|d krê|jd dj|ƒƒx&|D]}|j|d d�sÄtjd |ƒqÄW�nj|dk�r8|jddj|ƒƒx*|D]"}|j|d d��stjd|ƒ�qW�n|dk�rŠ|jd|dj|ƒfƒx,|D]$}|j||d��s`tjd||ƒ�q`WnÊ|dk�rÜ|jd|dj|ƒfƒx¦|D]$}|j||d��s²tjd||ƒ�q²Wnx|dk�r|jd|ƒ|jd|d��sTtjd|ƒnB|dk�rH|jd|ƒ|jd|d��sTtjd|ƒn td|ƒ‚dS)Nr&zinclude ú r )Úanchorz%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 rcCspd}t||||ƒ}|jd|jƒ|jdkr4|jƒx6|jD],}|j|ƒr<|jd|ƒ|jj|ƒd}qr;r<r r r r rs     L ,rcCs&dd„tj|dd�Dƒ}ttjj|ƒS)z% Find all files under 'path' css,|]$\}}}|D]}tjj||ƒVqqdS)N)rrr)r+ÚbaseÚdirsrÚfiler r r ú ûsz#_find_all_simple..T)Ú followlinks)rÚwalkÚfilterrÚisfile)rZresultsr r r Ú_find_all_simpleösrRcCs6t|ƒ}|tjkr.tjtjj|d�}t||ƒ}t|ƒS)zŒ Find all files under 'dir' and return the list of full filenames. Unless dir is '.', return full filenames with dir prepended. )Ústart) rRrrIÚ functoolsÚpartialrÚrelpathrÚlist)rrZmake_relr r r rs   rcCs8tj|ƒ}tj}tjdkrd}d|}tjd||ƒ}|S)zæTranslate a shell-like glob pattern to a regular expression; return a string containing the regex. Differs from 'fnmatch.translate()' in that '*' does not match "special characters" (which are platform-specific). ú\z\\\\z\1[^%s]z((?s  i