U e5dbã@spdZddlZddlZddlmZmZddlmZiaddd„Z dd d „Z dd d „Z d d„Z ddd„Z dd„ZdS)zWdistutils.dir_util Utility functions for manipulating directories and directory trees.éN)ÚDistutilsFileErrorÚDistutilsInternalError)Úlogéÿéc Csft|tƒstd|fƒ‚tj |¡}g}tj |¡s<|dkr@|St tj  |¡¡rV|Stj  |¡\}}|g}|rž|ržtj |¡sžtj  |¡\}}|  d|¡ql|D]¾}tj  ||¡}tj  |¡} t | ¡rÌq¢|dkràt  d|¡|sXzt ||¡WnVtk rL} z6| jtjkr&tj |¡stk rt} z |rRg} ntd|| jfƒ‚W5d} ~ XYnX|s†t ||dg} | D]Ê} tj  || ¡} tj  || ¡}|   d¡rºqŽ|r tj  | ¡r t  | ¡}|dkrît d ||¡|sþt ||¡|  |¡qŽtj | ¡r8|  t| |||||||d ¡qŽ|| ||||||d |  |¡qŽ| 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 '%s': %sN)rz.nfsrzlinking %s -> %sr&)Zdistutils.file_utilr/r r rrÚlistdirrÚstrerrorr%rÚ startswithÚislinkÚreadlinkrrÚsymlinkrÚextendÚ copy_tree)ÚsrcZdstZ preserve_modeZpreserve_timesZpreserve_symlinksÚupdaterrr/ÚnamesÚeZoutputsÚnZsrc_nameZdst_nameZ link_destr#r#r$r7cs\ ÿ ÿ     þÿþ r7cCsft |¡D]F}tj ||¡}tj |¡r@tj |¡s@t||ƒq | tj|f¡q | tj |f¡dS)zHelper for remove_tree().N) r r0r rrr3Ú_build_cmdtuplerÚremoveÚrmdir)r Ú cmdtuplesÚfZreal_fr#r#r$r=¨s  r=c Csœ|dkrt d|¡|rdSg}t||ƒ|D]h}z2|d|dƒtj |d¡}|tkrbt|=Wq.tk r”}zt d||¡W5d}~XYq.Xq.dS)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) rrr=r r rrrÚwarn)Z directoryrrr@Úcmdrr"r#r#r$Ú remove_tree²s   rDcCs6tj |¡\}}|dd…tjkr2||dd…}|S)z†Take the full path 'path', and make it a relative path. This is useful to make 'path' the second argument to os.path.join(). rrN)r r Ú splitdriveÚsep)r Zdriver#r#r$Úensure_relativeÊsrG)rrr)rrr)rrrrrr)rr)Ú__doc__r rZdistutils.errorsrrZ distutilsrrr%r.r7r=rDrGr#r#r#r$Ús   ? ÿ E