1jNdZddlZddlZddlZddlZddlmZddlmZddl m Z m Z Gdde Z e jZejedd ejd dfd Zejd efdZejddZddZ ddZdZdZddZdZdS)zWdistutils.dir_util Utility functions for manipulating directories and directory trees.N) file_util)log)DistutilsFileErrorDistutilsInternalErrorc>eZdZdZdZefdZdZxZS)SkipRepeatAbsolutePathsz Cache for mkpath. In addition to cheapening redundant calls, eliminates redundant "creating /foo/bar/baz" messages in dry-run mode. c|t_dSN)r instance)selfs U/opt/cloudlinux/venv/lib64/python3.11/site-packages/setuptools/_distutils/dir_util.py__init__z SkipRepeatAbsolutePaths.__init__s+/(((cVt||jdSr )superr clear)cls __class__s rrzSkipRepeatAbsolutePaths.clears' c3<  &&(((((rcJtjfd}|S)Nc|vrdS|g|Ri|}||Sr )absoluteadd)pathargskwargsresultfuncr s rwrapperz-SkipRepeatAbsolutePaths.wrap..wrappersY}}$&&T$000000F HHT]]__ % % %Mr) functoolswraps)r rrs`` rwrapzSkipRepeatAbsolutePaths.wraps>           r) __name__ __module__ __qualname____doc__r classmethodrr" __classcell__)rs@rr r sl000))))[)       rr Tnamereturnc|r)|stjd| ||dddS#t$r%}t d|d|jdd}~wwxYw)aCreate a directory and any missing ancestor directories. If the directory already exists (or if 'name' is the empty string, which means the current directory, which of course exists), then do nothing. Raise DistutilsFileError if unable to create some directory along the way (eg. some sub-path exists, but is a file rather than a directory). If 'verbose' is true, log the directory created. z creating %sT)modeparentsexist_okzcould not create '': N)is_dirrinfomkdirOSErrorrr)r*r-verboseexcs rmkpathr8.s&t{{}}& %%%O dT ::::: OOO !Md!M!Msx|!M!MNNNOsA A6 A11A6cFttj|g|Ri|Sr )r8pathlibPathr*rrs r_r=Bs* ',t$$ 6t 6 6 6v 6 66rc(td|d)z. Detect a common bug -- name is None. z%mkpath: 'name' must be a string (got ))rr<s rr=r=Gs !!R!R!R!R S SSrctfd|D}t|D]}t|||dS)aCreate all the empty directories under 'base_dir' needed to put 'files' there. 'base_dir' is just the name of a directory which doesn't necessarily exist yet; 'files' is a list of filenames to be interpreted relative to 'base_dir'. 'base_dir' + the directory portion of every file in 'files' will be created if it doesn't already exist. 'mode' and 'verbose' flags are as for 'mkpath()'. c3K|]A}tjtj|VBdSr )osrjoindirname).0filebase_dirs r zcreate_tree..ZsASST27<<"'//$*?*?@@SSSSSSrr6N)setsortedr8)rGfilesr-r6need_dirdirs` r create_treerOOsbSSSSUSSSSSHh++sD'*****++rFc tj|std|d tj|}n,#t $r}td|d|jd}~wwxYwt||tj t|||||||} ttj t| |S)aCopy an entire directory tree 'src' to a new location 'dst'. Both 'src' and 'dst' must be directory names. If 'src' is not a directory, raise DistutilsFileError. If 'dst' does not exist, it is created with 'mkpath()'. The end result of the copy is that every file in 'src' is copied to 'dst', and directories under 'src' are recursively copied to 'dst'. Return the list of files that were copied or might have been copied, using their output name. The return value is unaffected by 'update': it is simply the list of all files under 'src', with the names changed to be under 'dst'. 'preserve_mode' and 'preserve_times' are the same as for 'copy_file'; note that they only apply to regular files, not to directories. If 'preserve_symlinks' is true, symlinks will be copied as symlinks (on platforms that support them!); otherwise (the default), the destination of the symlink will be copied. 'update' and 'verbose' are the same as for 'copy_file'. zcannot copy tree 'z': not a directoryzerror listing files in 'r0NrI)srcdstpreserve_symlinksr6 preserve_modepreserve_timesupdate)rBrisdirrlistdirr5strerrorr8r partial _copy_onelist itertoolschain from_iterablemap) rQrRrTrUrSrVr6namesecopy_ones r copy_treerdas8 7==  O !Mc!M!M!MNNNR 3 RRR !PC!P!PAJ!P!PQQQR 3       +#%   H  --c(E.B.BCC D DDsA A2A--A2c #FKtj||}tj||} |drdS|rjtj|rKtj|} |dkrt jd| | tj| | | VdStj |rt|| |||||Ed{VdStj || ||||| VdS)Nz.nfsrzlinking %s -> %srI) rBrrC startswithislinkreadlinkrr3symlinkrWrdr copy_file) r*rQrRrSr6rTrUrVsrc_namedst_name link_dests rr[r[s[w||C&&Hw||C&&H vRW^^H55K)) a<< H'9 = = = 9h''' x                              rctj|D]}tj||}tj|r0tj|st ||q|tj|f|tj |fdS)zHelper for remove_tree().N) rBrXrrCrWrg_build_cmdtupleappendremovermdir)r cmdtuplesfreal_fs rroros Z  22dA&& 7==  2)?)? 2 FI . . . .   bi0 1 1 1 1 bh%&&&&&rc&|dkrtjd|g}t|||D]`} |d|dt4#t $r }tjd||Yd}~Yd}~wwxYwdS)zRecursively remove an entire directory tree. Any errors are ignored (apart from being reported to stdout if 'verbose' is true). rz'removing '%s' (and everything under it)rzerror removing %s: %sN)rr3ror rr5warning) directoryr6rscmdr7s r remove_treerzs !|| :IFFFIIy)))AA A CF3q6NNN # ) ) + + + + A A A K/C @ @ @ @ @ @ @ @ A AAs0A$$ B.B  Bctj|\}}|ddtjkr ||ddz}|S)zTake the full path 'path', and make it a relative path. This is useful to make 'path' the second argument to os.path.join(). rrN)rBr splitdrivesep)rdrives rensure_relativersI '$$T**KE4 AaCyBFtABBx Kr)r)T)r*N)TTFFT)T)r&r r]rBr:r_logrerrorsrrrJr r"rsingledispatchr;r8registerstrr=rOrdr[rorzrrrrsGG >>>>>>>>c8 " ! # # ( OOODOOO O$7C7777TTTT++++*  /E/E/E/Ed,,,^'''AAAA&r