B Re_4@sdZddlZddlZddlZddlZddlmZddlmZm Z ddl m Z GdddZ dd Z Gd d d eZejfd d ZddZdddZdS)zsdistutils.filelist Provides the FileList class, used for poking about the filesystem and building lists of files. N) convert_path)DistutilsTemplateErrorDistutilsInternalError)logc@s|eZdZdZdddZddZejfddZd d Z d d Z d dZ ddZ ddZ ddZddZdddZdddZdS) FileListaA 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)allfilesfiles)selfwarn debug_printr /builddir/build/BUILDROOT/alt-python37-setuptools-58.3.0-4.el8.x86_64/opt/alt/python37/lib/python3.7/site-packages/setuptools/_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)distutils.debugrprint)r msgrr r r r ,s zFileList.debug_printcCs|j|dS)N)rappend)r itemr r r r6szFileList.appendcCs|j|dS)N)rextend)r itemsr r r r9szFileList.extendcCs@tttjj|j}g|_x |D]}|jtjj|q WdS)N)sortedmapospathsplitrrjoin)r Zsortable_filesZ sort_tupler r r sort<s z FileList.sortcCsDx>tt|jdddD]$}|j||j|dkr|j|=qWdS)Nr)rangelenr)r ir r r remove_duplicatesEszFileList.remove_duplicatescCs|}|d}d}}}|dkrTt|dkr ...cSsg|] }t|qSr )r).0wr r r Xsz1FileList._parse_template_line..r!)zrecursive-includezrecursive-excludez,'%s' expects ...cSsg|] }t|qSr )r)r*r+r r r r,^s)graftprunez#'%s' expects a single zunknown action '%s')rr$rr)r linewordsactionpatternsr dir_patternr r r _parse_template_lineMs*         zFileList._parse_template_linecCs\||\}}}}|dkrZ|dd|x&|D]}|j|dds4td|q4Wn|dkr|dd|x&|D]}|j|dds|td |q|Wn|d kr|d d|x&|D]}|j|d dstd |qWnn|dkr8|dd|x*|D]"}|j|d dstd|qWn |dkr|d|d|fx|D](}|j||ds`d}t|||q`Wn|dkr|d|d|fx|D]$}|j||dstd||qWnx|dkr|d||jd|dsXtd|nB|dkrL|d||jd|dsXtd|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'r.zgraft z+warning: no directories found matching '%s'r/zprune z6no previously-included directories found matching '%s'z'this cannot happen: invalid action '%s')r5r rinclude_patternrr exclude_patternr)r r0r2r3rr4patternrr r r process_template_lineisf           zFileList.process_template_liner!rcCspd}t||||}|d|j|jdkr4|x6|jD],}||r<|d||j|d}q)r r;r7r8r?r@rAr%r r r r:s zFileList.exclude_pattern)NN)r!Nr)r!Nr)__name__ __module__ __qualname____doc__rrrcurdirrr rrr r&r5r<r9r:r r r r rs    M +rcCs0ttj|dd}dd|D}ttjj|S)z% Find all files under 'path' T) followlinkscss,|]$\}}}|D]}tj||VqqdS)N)rrr)r*basedirsrfiler r r sz#_find_all_simple..) _UniqueDirsfilterrwalkrisfile)rZ all_uniqueresultsr r r _find_all_simplesrRc@s$eZdZdZddZeddZdS)rMz Exclude previously-seen dirs from walk results, avoiding infinite recursion. Ref https://bugs.python.org/issue44497. cCsF|\}}}t|}|j|jf}||k}|r6|dd=||| S)z Given an item from an os.walk result, determine if the item represents a unique dir for this instance and if not, prevent further traversal. N)rstatst_devst_inoadd)r Z walk_itemrIrJrrS candidatefoundr r r __call__ s     z_UniqueDirs.__call__cCs t||S)N)rN)clsrr r r rNsz_UniqueDirs.filterN)rCrDrErFrY classmethodrNr r r r rMsrMcCs6t|}|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) rRrrG functoolspartialrrelpathrlist)rrZmake_relr r r rs   rcCs8t|}tj}tjdkrd}d|}td||}|S)zTranslate 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  f