bgDPdZddlZddlZddlZddlZddlmZddlmZddl m Z m Z Gdde Z e jZejedd ejd dfdZejd 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 TFnamereturnc|r)|stjd| |p||dddSdS#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-verbosedry_runexcs rmkpathr9.s&t{{}}& %%%OE4::4:EEEEEEEE OOO !Md!M!Msx|!M!MNNNOsA A A; A66A;cFttj|g|Ri|Sr )r9pathlibPathr*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', 'verbose' and 'dry_run' flags are as for 'mkpath()'. c3K|]A}tjtj|VBdSr )osrjoindirname).0filebase_dirs r zcreate_tree..ZsASST27<<"'//$*?*?@@SSSSSSrr6r7N)setsortedr9)rHfilesr-r6r7need_dirdirs` r create_treerPOsdSSSSUSSSSSHh<<sD'7;;;;;<A99A>c #NKtj||} tj||} |drdS|rltj| rMtj| } |dkrt jd| | |stj| | | VdStj | rt| | ||||||Ed{VdStj | | |||||| VdS)Nz.nfsrzlinking %s -> %srJ) rCrrD startswithislinkreadlinkrr3symlinkrXrer copy_file) r*rRrSrTr6r7rUrVrWsrc_namedst_name link_dests rr\r\siw||C&&Hw||C&&H vRW^^H55K)) a<< H'9 = = = , Jy( + + + x                     rctj|D]}tj||}tj|r0tj|st ||q|tj|f|tj |fdS)zHelper for remove_tree().N) rCrYrrDrXrh_build_cmdtupleappendremovermdir)r cmdtuplesfreal_fs rrprps Z  22dA&& 7==  2)?)? 2 FI . . . .   bi0 1 1 1 1 bh%&&&&&rc.|dkrtjd||rdSg}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)Nrzerror removing %s: %s)rr3rpr rr5warning) directoryr6r7rtcmdr8s r remove_treer{s !|| :IFFFIIy)))AA A CF3q6NNN # ) ) + + + + A A A K/C @ @ @ @ @ @ @ @ A AAs0A(( B2B  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)rCr splitdrivesep)rdrives rensure_relativersI '$$T**KE4 AaCyBFtABBx Kr)r)TF)r*N)TTFFTF)TF)r&r r^rCr;r_logrerrorsrrrKr r"rsingledispatchr<r9registerstrr>rPrer\rpr{rrrrsGG >>>>>>>>c8 " ! # # ( OOO4OOO O$7C7777TTTT<<<<*   5E5E5E5Ep000f'''AAAA*r