bgV5dZddlZddlZddlZddlZddlmZddlmZm 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)log)DistutilsInternalErrorDistutilsTemplateError convert_pathcneZdZdZddZdZejfdZdZ 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 U/opt/cloudlinux/venv/lib64/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|dd|ddD}n|dvrPt|d krtd|d t|d}d |ddD}nS|d vr ...c,g|]}t|Sr.0ws r z1FileList._parse_template_line..Y;;;A Q;;;rr)recursive-includerecursive-excludez)' expects ...c,g|]}t|Sr=rr>s rrAz1FileList._parse_template_line..`rBr)graftprunez ' expects a single zunknown action ')r*r2rr)rlinewordsactionpatternsr dir_patterns r_parse_template_linezFileList._parse_template_lineNse q'+++3 O O O5zzA~~,CCCC<;qrr;;;HH A A A5zzA~~,IIIIuQx((C;;qrr;;;HH ) ) )5zzQ,@@@@'uQx00KK()EF)E)E)EFF F#{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|d) Nr6zinclude  T)anchorz%warning: no files found matching '%s'r7zexclude z9warning: no previously-included files found matching '%s'r8zglobal-include Fz>warning: no files found matching '%s' anywhere in distributionr9zglobal-exclude zRwarning: no previously-included files matching '%s' found anywhere in distributionrCzrecursive-include {} {})prefixz:warning: no files found matching '%s' under directory '%s'rDzrecursive-exclude {} {}zNwarning: no previously-included files matching '%s' found under directory '%s'rGzgraft z+warning: no directories found matching '%s'rHzprune z6no previously-included directories found matching '%s'z$this cannot happen: invalid action 'r;) rNrr+include_patternrwarningexclude_patternformatr)rrIrKrLrrMpatternrs rprocess_template_linezFileList.process_template_linelsM 04/H/H/N/N,3 Y     Z#((8*<*<< = = =# R R++GD+AARK GQQQ R Ry   Z#((8*<*<< = = =#  ++GD+AAK2   ' ' '   .(1C1CC D D D#  ++GE+BBK7   ' ' '   .(1C1CC D D D#  ++GE+BBKB   * * *   6==c388HCUCUVV W W W# 3 3++GC+@@3VCKWc222 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  M   )@v@@@ rTFcFd}t||||}|d|jd|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'r;Nz adding T)translate_patternrrWr rsearchrr )rrWrQrRis_regex files_found pattern_renames rrSzFileList.include_patterns4 &wII  Sj>PSSSTTT = LLNNNM # #D  && #  d!2333 !!$'''" rcVd}t||||}|d|jdtt |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'r;rr0z removing T)rZrrWr1r2rr[)rrWrQrRr\r]r^r3s rrUzFileList.exclude_patterns &wII  Sj>PSSSTTTs4:*B33 # #A  A// #   1 !=>>>JqM" r)NNTNF)__name__ __module__ __qualname____doc__rrr(curdirrrr r#r.r4rNrXrSrUr=rrr r s   !!!)%%%%   !!!999"""444z#_find_all_simple.. s^%6T4QVIM T4  r) _UniqueDirsfilterr(walkr)isfile)r) all_uniqueresultss r_find_all_simplertsZ##BGDd$C$C$CDDJ:DG "'.' * **rc.eZdZdZdZedZdS)rnz 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_itemrjrkrrw candidatefounds r__call__z_UniqueDirs.__call__sb &dEwt}}K, T!  QQQ yrc2t||Sr )ro)clsr$s rroz_UniqueDirs.filter'scceeU###rN)rbrcrdrer~ classmethodror=rrrnrnsH   $$[$$$rrnct|}|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) rtr(rf functoolspartialr)relpathr'list)rrmake_rels rrr,sR S ! !E bi$RW_C@@@He$$ ;;rctj|}tj}tjdkrd}d|d}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[^]z((?>CHH+DDE f 6T>>CE S__s3xx-G GH EE)ESEEJEEE  A"@@jU&>@@J :j ! !!rra)rerrr(r_logrerrorsrrutilrr rtsetrnrfrrrZr=rrrs&  BBBBBBBBooooooooj+++$$$$$#$$$6    .""""""""""""r