WcbjdZddlZddlZddlmZmZddlmZiad dZ d dZ dd Z d Z dd Z d ZdS)zWdistutils.dir_util Utility functions for manipulating directories and directory trees.N)DistutilsFileErrorDistutilsInternalError)logc t|tstd|dtjj |}g}tjj |s|dkr|Stjtjj|r|Stjj|\}}|g}|r|r~tjj |s]tjj|\}}|jd||r$|r"tjj |s]|D]}tjj||}tjj|} tj| r^|dkrtjd||s+ tj|||j+|dt| <|S#t $rm} | j"t"j$kr!tjj |s#t'd|d| j(d Yd } ~ d } ~ 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, print a one-line summary of each mkdir to stdout. Return the list of directories actually created. z%mkpath: 'name' must be a string (got )rrz creating %szcould not create '': N) isinstancestrrospathnormpathisdir _path_createdgetabspathsplitinsertjoinrinfomkdirOSErrorerrnoEEXISTrargsappend) namemodeverbosedry_run created_dirsheadtailtailsdabs_headexcs +/usr/lib64/python3.12/distutils/dir_util.pymkpathr,s5 dC $$<@DDBD D 77  D !DL ww}}Tdbjj.//77==<4 FE $44 d 3 3ww}}T* t Q $44 d 3 3$$ww||D!$77??4(   X & &  a<< HH]D ) )w Nt$$    % %"# h  N N N U\\11bggmmD6I6I,,9=sxx||LNN7J6I6I6I6I NsH  JA#I<<Jc t}|D]S}|jtjj |tjj |Ut |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_treer8PsuHDD RWW\\(BGGOOD,ABCCCh<<sD'7;;;;<<c ddlm}|s1tjj |st d|z tj |} |st||g} | D]J} tjj|| } tjj|| }| jdr[|rtjj| rctj| }|d krtjd |||stj ||| j#|tjj | r'| j%t'| ||||||| )|| |||||| | j#|M| S#t$r-} |rg} nt d|d| jYd} ~ d} ~ wwxYw) 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 'r N)r"z.nfsrzlinking %s -> %sr.)distutils.file_utilr;rrrrlistdirrstrerrorr,r startswithislinkreadlinkrrsymlinkrextend copy_tree)srcdst preserve_modepreserve_timespreserve_symlinksupdater"r#r;nameseoutputsnsrc_namedst_name link_dests r+rDrDcs*.----- 7277==-- 6<> >I 3 7sG$$$G %%77<<Q'77<<Q' <<     !9!9 H-I!||+XyAA7 9h// NN8 $ $ $ WW]]8 $ $ NN(Hm(*;V")7<< = = = Ih-$fg% ' ' ' NN8 $ $ $ NO III 7EE$$7:ssAJJJGI I EEEEIsF66 G-"G((G-ctj|D]}tjj||}tjj |r0tjj |st ||v|jtj|f|jtj|fdS)zHelper for remove_tree().N) rr=rrrr@_build_cmdtuplerremovermdir)r cmdtuplesfreal_fs r+rSrSs ZZ 22d1% 77== )?)? FI . . .   bii0 1 1 1 bhh%&&&&r9cr|dkrtjd||rdSg}t|||D]P} |d|dtjj |d}|t vrt |=RdS#t$r#}tjd||Yd}~|d}~wwxYw)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) rrrSrrrrrwarn) directoryr"r#rVcmdrr*s r+ remove_treer]s!|| :IFFwIIy))>> > CF3q6NNggooc!f-G-''!'* >> > > > HH,i = = = = = = = >sA B  B6B11B6ctjj|\}}|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_relativerbsF ''$$T*KE4 AayBFFtABx Kr9)rrr)rrrrrr)rr)__doc__rrdistutils.errorsrr distutilsrrr,r8rDrSr]rbr9r+rgsGG GGGGGGGG ====~<<<<&9:@ACCCCJ'''>>>>0r9