efrdZddlZddlZddlmZmZddlmZiad dZ d dZ dd Z d Z dd Z d ZdS)zWdistutils.dir_util Utility functions for manipulating directories and directory trees.N)DistutilsInternalErrorDistutilsFileError)logc t|ts"td|tj|}g}tj|s|dkr|St tj |r|Stj |\}}|g}|r||rztj|s[tj |\}}| d||r!|rtj|[|D])}tj ||}tj |} t | r]|dkrtjd||s t j||ny#t"$rl} | jt$jkrtj|s.t)d|| jdYd} ~ nd} ~ wwxYw||dt| <+|S) 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, print a one-line summary of each mkdir to stdout. Return the list of directories actually created. os.makedirs is not used because: a) It's new to Python 1.5.2, and b) it blows up if the directory already exists (in which case it should silently succeed). z*mkpath: 'name' must be a string (got {!r})rrz creating %szcould not create '{}': {}N) isinstancestrrformatospathnormpathisdir _path_createdgetabspathsplitinsertjoinrinfomkdirOSErrorerrnoEEXISTrargsappend) namemodeverbosedry_run created_dirsheadtailtailsdabs_headexcs ~/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/setuptools/_distutils/dir_util.pymkpathr+sk( dC  $ 8 ? ? E E    7  D ! !DL w}}Tdbjj..//7==&<4 FE 4 d 3 3w}}T** t Q 4 d 3 3$$w||D!$$7??4((   X & &   a<< H]D ) ) ) & t$$$$    U\11bgmmD6I6I1,3::4"NN21111     % % %"# h sG// I%9A"I  I%c t}|D]R}|tj|tj|St |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', 'verbose' and 'dry_run' flags are as for 'mkpath()'. r!r"N)setaddrrrdirnamesortedr+)base_dirfilesr r!r"need_dirfiledirs r* create_treer7WsuuHDD RW\\(BGOOD,A,ABBCCCCh<<sD'7;;;;;<<c ddlm}|s1tj|st d|z tj|} nD#t$r7} |rg} n(t d|| j Yd} ~ nd} ~ wwxYw|st||g} | D]I} tj || } tj || }| drY|r|tj | r]tj| }|dkrtjd |||stj||| |tj| r,| t)| ||||||| "|| |||||| | |K| 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' or 'dry_run': 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'. r) copy_filez&cannot copy tree '%s': not a directoryzerror listing files in '{}': {}N)r!z.nfsrzlinking %s -> %sr-)distutils.file_utilr:rrrrlistdirrr strerrorr+r startswithislinkreadlinkrrsymlinkrextend copy_tree)srcdst preserve_modepreserve_timespreserve_symlinksupdater!r"r:nameseoutputsnsrc_namedst_name link_dests r*rCrCksQ:.----- Q27==--Q !IC!OPPP 3   EE$188ajII  EEEE %sG$$$$G '%'%7<<Q''7<<Q'' <<      %!9!9 % H--I!||+XyAAA 0 9h/// NN8 $ $ $ $ W]]8 $ $ % NN!"%##        I     NN8 $ $ $ $ NsA B-B  Bctj|D]}tj||}tj|r0tj|st ||q|tj|f|tj |fdS)zHelper for remove_tree().N) rr<rrrr?_build_cmdtuplerremovermdir)r cmdtuplesfreal_fs r*rRrRs Z  22dA&& 7==  2)?)? 2 FI . . . .   bi0 1 1 1 1 bh%&&&&&r8c|dkrtjd||rdSg}t|||D]} |d|dtj|d}|t vrt |c#t$r }tj d||Yd}~d}~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)Nrzerror removing %s: %s) rrrRrrrrpoprwarning) directoryr!r"rUcmdrr)s r* remove_treer]s!|| :IFFFIIy)))AA A CF3q6NNNgooc!f--G-''!!'*** A A A K/C @ @ @ @ @ @ @ @ AAAsAB C!B<<Cctj|\}}|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)rr splitdrivesep)rdrives r*ensure_relativerbsI '$$T**KE4 AaCyBFtABBx Kr8)rrr)rrrrrr)rr)__doc__rrerrorsrr_logrrr+r7rCrRr]rbr8r*rgsGG >>>>>>>> EEEEP<<<<. YYYYx'''AAAA2r8