VULN_CHECK_I913V6 SSh5dZddlZddlZddlZddlZddlmZddlmZm Z ddl m Z GddZ d Z Gd d eZej fd Zd ZddZy)zsdistutils.filelist Provides the FileList class, used for poking about the filesystem and building lists of files. N) convert_path)DistutilsTemplateErrorDistutilsInternalError)logcveZdZdZddZdZejfdZdZ dZ dZ d Z d Z d Zd Zdd ZddZy)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) Nc d|_g|_yN)allfilesfiles)selfwarn debug_prints C/usr/lib/python3.12/site-packages/setuptools/_distutils/filelist.py__init__zFileList.__init__ s  c||_yr )r )rr s r set_allfileszFileList.set_allfiles&s   rc$t||_yr )findallr )rdirs rrzFileList.findall)s   rc,ddlm}|r t|yy)z~Print 'msg' to stdout if the global DEBUG (taken from the DISTUTILS_DEBUG environment variable) flag is true. r)DEBUGN)distutils.debugrprint)rmsgrs rrzFileList.debug_print,s *  #J rc:|jj|yr )r append)ritems rrzFileList.append7s $rc:|jj|yr )r extend)ritemss rr"zFileList.extend:s % rctttjj|j }g|_|D]7}|j j tjj|9yr )sortedmapospathsplitr rjoin)rsortable_files sort_tuples rsortz FileList.sort=sOBGGMM4:: >? (J JJ  bggllJ7 8)rctt|jdz ddD]2}|j||j|dz k(s&|j|=4y)Nrr)rangelenr )ris rremove_duplicateszFileList.remove_duplicatesFsJs4::*Ar2Azz!} 1q5 11JJqM3rc|j}|d}dx}x}}|dvr8t|dkrtd|z|ddDcgc] }t|}}n|dvrFt|dkrtd|zt|d}|ddDcgc] }t|}}n=|d vr+t|dk7rtd |zt|d}ntd |z||||fScc}wcc}w) Nr)includeexcludeglobal-includeglobal-excludez&'%s' expects ...r)recursive-includerecursive-excludez,'%s' expects ...)graftprunez#'%s' expects a single zunknown action '%s')r)r1rr)rlinewordsactionpatternsr dir_patternws r_parse_template_linezFileList._parse_template_lineNs( q'+++3 O O5zA~,)GH H#{33#<warning: no files found matching '%s' anywhere in distributionr8zglobal-exclude zRwarning: no previously-included files matching '%s' found anywhere in distributionr:zrecursive-include {} {})prefixz:warning: no files found matching '%s' under directory '%s'r;zrecursive-exclude {} {}zNwarning: 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') rErr*include_patternrwarningexclude_patternformatr)rr?rArBrrCpatternrs rprocess_template_linezFileList.process_template_linels 04/H/H/N,3 Y    Z#((8*<< =#++GA+>KK GQ$y   Z#((8*<< =#++GA+>KK2 $' '   .(1CC D#++GA+>KK7 $' '   .(1CC D#++GA+>KKB $* *   6==c388HCUV W#++GC+@WKKWc2 $* *   6==c388HCUV W#++GC+@KK>  $w    X 3 4''['A I;WBw    X 3 4''['A PB )9FB rcBd}t||||}|jd|jz|j|j |jD]E}|j |s|jd|z|j j|d}G|S)aSelect strings (presumably filenames) from 'self.files' that match 'pattern', a Unix-style wildcard (glob) pattern. Patterns are not quite the same as implemented by the 'fnmatch' module: '*' and '?' match non-special characters, where "special" is platform- dependent: slash on Unix; colon, slash, and backslash on DOS/Windows; and colon on Mac OS. If 'anchor' is true (the default), then the pattern match is more stringent: "*.py" will match "foo.py" but not "foo/bar.py". If 'anchor' is false, both of these will match. If 'prefix' is supplied, then only filenames starting with 'prefix' (itself a pattern) and ending with 'pattern', with anything in between them, will match. 'anchor' is ignored in this case. If 'is_regex' is true, 'anchor' and 'prefix' are ignored, and 'pattern' is assumed to be either a string containing a regex or a regex object -- no translation is done, the regex is just compiled and used as-is. Selected strings will be added to self.files. Return True if files are found, False otherwise. Fz%include_pattern: applying regex r'%s'z adding T)translate_patternrrNr rsearchr r)rrNrHrIis_regex files_found pattern_renames rrJzFileList.include_patterns4 &wI  @:CUCUUV == LLNMMD  &  d!23 !!$'" " rcPd}t||||}|jd|jztt |j dz ddD]Q}|j |j |s"|jd|j |z|j |=d}S|S)aRemove strings (presumably filenames) from 'files' that match 'pattern'. Other parameters are the same as for 'include_pattern()', above. The list 'self.files' is modified in place. Return True if files are found, False otherwise. Fz%exclude_pattern: applying regex r'%s'rr/z removing T)rQrrNr0r1r rR)rrNrHrIrSrTrUr2s rrLzFileList.exclude_patterns &wI  @:CUCUUVs4::*B3A  A/   1 !=>JJqM" 4 r)NNrNr)__name__ __module__ __qualname____doc__rrr'curdirrrrr"r-r3rErOrJrLrrr r sO  !))% !9"4z#_find_all_simple.. s5:D%6T4QV T4 QV *s57) _UniqueDirsfilterr'walkr(isfile)r( all_uniqueresultss r_find_all_simplermsE##BGGDd$CDJ:DG "''..' **rc&eZdZdZdZedZy)rgz Exclude previously-seen dirs from walk results, avoiding infinite recursion. Ref https://bugs.python.org/issue44497. c|\}}}tj|}|j|jf}||v}|r|dd=|j || 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)r'statst_devst_inoadd)r walk_itemrcrdr rp candidatefounds r__call__z_UniqueDirs.__call__sW &dEwwt}KK, T! Q yrc$t||Sr )rh)clsr#s rrhz_UniqueDirs.filter)sceU##rN)rYrZr[r\rw classmethodrhr^rrrgrgs  $$rrgct|}|tjk(r;tjtj j |}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) rmr'r] functoolspartialr(relpathr&list)rr make_rels rrr.sJ S !E bii$$RWW__C@He$ ;rctj|}tj}tjdk(rd}d|z}t j d||}|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((?CH+DE ff 66T>CE S_s3x-GH &--eYZQTU "))%CJL1IJJ ::j !!rrX)r\r'rrr}utilrerrorsrr_logrr rmsetrgr]rrrQr^rrrsW  Bqqn+$#$6 .""r