qfc@sdZdZddlZddlZddlmZmZddlmZia dddd Z dddd Z ddddddd Z d Z ddd ZdZdS(sWdistutils.dir_util Utility functions for manipulating directories and directory trees.s$Id$iN(tDistutilsFileErrortDistutilsInternalError(tlogiiic Cst|ts"td|fntjj|}g}tjj|sX|dkr\|Stjtjj |r{|Stjj |\}}|g}xK|r|rtjj| rtjj |\}}|j d|qWx|D]}tjj ||}tjj |} tj| r3qn|dkrRt jd|n|sytj||WnWtk r} | jtjkotjj|std|| jdfqnX|j|ndt|  "  $!c Csi}x3|D]+}d|tjj|tjj|tjk r\} } |rwg} qtd|| fnX|st|d|ng} x1| D])} tjj || }tjj || }| j drqn|rktjj |rktj |}|dkrBt jd||n|s[tj||n| j|qtjj|r| jt||||||d|d |q||||||d|d || j|qW| S( sCopy 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'. i(t copy_files&cannot copy tree '%s': not a directoryserror listing files in '%s': %sRs.nfsislinking %s -> %sR(tdistutils.file_utilR-RRR RtlistdirterrorR"Rt startswithtislinktreadlinkRRtsymlinkRtextendt copy_tree(tsrctdstt preserve_modetpreserve_timestpreserve_symlinkstupdateRRR-tnamesRterrstrtoutputstntsrc_nametdst_namet link_dest((s*/usr/lib64/python2.7/distutils/dir_util.pyR6gsH       cCsxwtj|D]f}tjj||}tjj|r`tjj| r`t||q|jtj|fqW|jtj |fdS(sHelper for remove_tree().N( RR/RRR R2t_build_cmdtupleRtremovetrmdir(Rt cmdtuplestftreal_f((s*/usr/lib64/python2.7/distutils/dir_util.pyRDs %cCsddlm}|dkr/tjd|n|r9dSg}t||x|D]~}yB|d|dtjj|d}|tkrt|=nWqSt t fk r}tj ||d|qSXqSWdS(sRecursively remove an entire directory tree. Any errors are ignored (apart from being reported to stdout if 'verbose' is true). i(tgrok_environment_erroris'removing '%s' (and everything under it)Niserror removing %s: ( tdistutils.utilRJRRRDRRR R tIOErrorRtwarn(t directoryRRRJRGtcmdR R!((s*/usr/lib64/python2.7/distutils/dir_util.pyt remove_trees      cCsCtjj|\}}|dd!tjkr?||d}n|S(sTake the full path 'path', and make it a relative path. This is useful to make 'path' the second argument to os.path.join(). ii(RRt splitdrivetsep(Rtdrive((s*/usr/lib64/python2.7/distutils/dir_util.pytensure_relatives(t__doc__t __revision__RRtdistutils.errorsRRt distutilsRR R"R,R6RDRPRT(((s*/usr/lib64/python2.7/distutils/dir_util.pyts  ?D