ef5dZddlZddlZddlZddlZddlmZddlmZm Z ddl m Z GddZ d Z Gd d eZejfd Zd ZddZdS)zsdistutils.filelist Provides the FileList class, used for poking about the filesystem and building lists of files. N convert_path)DistutilsTemplateErrorDistutilsInternalError)logcneZdZdZddZdZejfdZdZ dZ dZ d Z d Z d Zd ZddZddZdS)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|_dSN)allfilesfiles)selfwarn debug_prints ~/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/setuptools/_distutils/filelist.py__init__zFileList.__init__ s  c||_dSr )r )rr s r set_allfileszFileList.set_allfiles&s   rc.t||_dSr )findallr )rdirs rrzFileList.findall)s  rc8ddlm}|rt|dSdS)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,s7 *)))))   #JJJJJ  rc:|j|dSr )rappend)ritems rr zFileList.append7s $rc:|j|dSr )rextend)ritemss rr#zFileList.extend:s %     rctttjj|j}g|_|D]-}|jtjj|.dSr )sortedmapospathsplitrr join)rsortable_files sort_tuples rsortz FileList.sort=saBGM4: > >?? ( 9 9J J  bglJ7 8 8 8 8 9 9rctt|jdz ddD])}|j||j|dz kr|j|=*dS)Nrr)rangelenr)ris rremove_duplicateszFileList.remove_duplicatesFsZs4:*Ar22 " "Az!} 1q5 111JqM " "rc|}|d}dx}x}}|dvr:t|dkrtd|zd|ddD}n|dvrOt|dkrtd |zt|d}d |ddD}nQ|d vr;t|dkrtd |zt|d}ntd |z||||fS)Nr)includeexcludeglobal-includeglobal-excludez&'%s' expects ...c,g|]}t|Sr.0ws r z1FileList._parse_template_line..Y;;;A Q;;;rr)recursive-includerecursive-excludez,'%s' expects ...c,g|]}t|Sr<rr=s rr@z1FileList._parse_template_line..`rAr)graftprunez#'%s' expects a single zunknown action '%s')r*r2rr)rlinewordsactionpatternsr dir_patterns r_parse_template_linezFileList._parse_template_lineNsM q'+++3 O O O5zzA~~,)GHH H#{33rc||\}}}}|dkr^|dd|z|D].}||dst jd|/dS|dkr^|dd|z|D].}||dst jd |/dS|d kr^|d d|z|D].}||d st jd |/dS|dkr^|dd|z|D].}||d st jd|/dS|dkrr|d|d||D]1}|||sd}t j|||2dS|dkrp|d|d||D]/}|||st jd||0dS|dkrH|d|z|d|st jd|dSdS|dkrH|d|z|d|st jd|dSdStd|z)Nr6zinclude  r)anchorz%warning: no files found matching '%s'r7zexclude z9warning: no previously-included files found matching '%s'r8zglobal-include rz>warning: no files found matching '%s' anywhere in distributionr9zglobal-exclude zRwarning: no previously-included files matching '%s' found anywhere in distributionrBzrecursive-include {} {})prefixz:warning: no files found matching '%s' under directory '%s'rCzrecursive-exclude {} {}zNwarning: no previously-included files matching '%s' found under directory '%s'rFzgraft z+warning: no directories found matching '%s'rGzprune z6no previously-included directories found matching '%s'z'this cannot happen: invalid action '%s') rMrr+include_patternrwarningexclude_patternformatr)rrHrJrKrrLpatternrs rprocess_template_linezFileList.process_template_linelsL 04/H/H/N/N,3 Y     Z#((8*<*<< = = =# R R++GA+>>RK GQQQ R Ry   Z#((8*<*<< = = =#  ++GA+>>K2   ' ' '   .(1C1CC D D D#  ++GA+>>K7   ' ' '   .(1C1CC D D D#  ++GA+>>KB   * * *   6==c388HCUCUVV W W W# 3 3++GC+@@3WKWc222  3 3* * *   6==c388HCUCUVV W W W#  ++GC+@@K>    w     X 3 4 4 4''['AA X I;WWWWW X Xw     X 3 4 4 4''['AA  P   )9FB rrrcDd}t||||}|d|jz|j||jD]K}||r4|d|z|j|d}L|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'Nz adding T)translate_patternrrVr rsearchrr )rrVrPrQis_regex files_found pattern_renames rrRzFileList.include_patterns4 &wII  @:CUUVVV = LLNNNM # #D  && #  d!2333 !!$'''" rcTd}t||||}|d|jztt |jdz ddD]O}||j|r-|d|j|z|j|=d}P|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'rr0z removing T)rYrrVr1r2rrZ)rrVrPrQr[r\r]r3s rrTzFileList.exclude_patterns &wII  @:CUUVVVs4:*B33 # #A  A// #   1 !=>>>JqM" r)NNrNr)__name__ __module__ __qualname____doc__rrr(curdirrrr r#r.r4rMrWrRrTr<rrr r s   !!!)%%%%   !!!999"""444basedirsrfiles r z#_find_all_simple.. s^%6T4QVIM T4  r) _UniqueDirsfilterr(walkr)isfile)r) all_uniqueresultss r_find_all_simplerssZ##BGDd$C$C$CDDJ:DG "'.' * **rc.eZdZdZdZedZdS)rmz Exclude previously-seen dirs from walk results, avoiding infinite recursion. Ref https://bugs.python.org/issue44497. c|\}}}tj|}|j|jf}||v}|r|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)r(statst_devst_inoadd)r walk_itemrirjrrv candidatefounds r__call__z_UniqueDirs.__call__sb &dEwt}}K, T!  QQQ yrc2t||Sr )rn)clsr$s rrnz_UniqueDirs.filter)scceeU###rN)rarbrcrdr} classmethodrnr<rrrmrmsH   $$[$$$rrmct|}|tjkr5tjtjj|}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) rsr(re functoolspartialr)relpathr'list)rrmake_rels rrr.sR S ! !E bi$RW_C@@@He$$ ;;rctj|}tj}tjdkrd}d|z}t jd||}|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((?>CHH+DDE f 6T>>CE S__s3xx-G GH &--eYZQTUU  K"))%CJJLL1IJJJ :j ! !!rr`)rdr(rrrutilrerrorsrr_logrr rssetrmrerrrYr<rrrs&  BBBBBBBBqqqqqqqqn+++$$$$$#$$$6    .""""""""""""r