ž «ÿf‚c@sœdZddlZddlmZddlmZidd6dd6dd 6Zdd d „Zdddddddd„Z dddd„Z dd„Z dS(uFdistutils.file_util Utility functions for operating on single files. iN(uDistutilsFileError(ulogucopyingu hard linkinguhardusymbolically linkingusymiicNCsd}d}zØyt|dƒ}WnAtjk re}ztd||jfƒ‚WYdd}~XnXtjj|ƒrÐytj|ƒWqÐtjk rÌ}ztd||jfƒ‚WYdd}~XqÐXnyt|dƒ}WnAtjk r&}ztd||jfƒ‚WYdd}~XnXx¹y|j |ƒ}WnAtjk r€}ztd||jfƒ‚WYdd}~XnX|s‹Pny|j |ƒWq*tjk rß}ztd||jfƒ‚WYdd}~Xq*Xq*Wd|rú|j ƒn|r |j ƒnXdS( u5Copy the file 'src' to 'dst'; both must be filenames. Any error opening either file, reading from 'src', or writing to 'dst', raises DistutilsFileError. Data is read/written in chunks of 'buffer_size' bytes (default 16k). No attempt is made to handle anything apart from regular files. urbucould not open '%s': %sNucould not delete '%s': %suwbucould not create '%s': %sucould not read from '%s': %sucould not write to '%s': %s( uNoneuopenuosuerroruDistutilsFileErrorustrerrorupathuexistsuunlinkureaduwriteuclose(usrcudstu buffer_sizeufsrcufdstueubuf((u8/opt/alt/python33/lib64/python3.3/distutils/file_util.pyu_copy_file_contentssF ,,))0 u_copy_file_contentsicCsšddlm}ddlm} m} m} m} tjj |ƒsWt d|ƒ‚ntjj |ƒr“|} tjj |tjj |ƒƒ}ntjj|ƒ} |rä|||ƒ rä|dkrÚtjd|ƒn|dfSyt|}Wn"tk rtd|ƒ‚YnX|dkrytjj |ƒtjj |ƒkr`tjd||| ƒqytjd|||ƒn|r‰|dfS|d krÒtjj|ƒo¹tjj||ƒstj||ƒqn¾|d krtjj|ƒotjj||ƒstj||ƒqnut||ƒ|s4|rtj|ƒ}|rjtj||| || fƒn|rtj|| || ƒƒqn|dfS( uáCopy a file 'src' to 'dst'. If 'dst' is a directory, then 'src' is copied there with the same name; otherwise, it must be a filename. (If the file exists, it will be ruthlessly clobbered.) If 'preserve_mode' is true (the default), the file's mode (type and permission bits, or whatever is analogous on the current platform) is copied. If 'preserve_times' is true (the default), the last-modified and last-access times are copied as well. If 'update' is true, 'src' will only be copied if 'dst' does not exist, or if 'dst' does exist but is older than 'src'. 'link' allows you to make hard links (os.link) or symbolic links (os.symlink) instead of copying: set it to "hard" or "sym"; if it is None (the default), files are copied. Don't set 'link' on systems that don't support it: 'copy_file()' doesn't check if hard or symbolic linking is available. Under Mac OS, uses the native file copy function in macostools; on other systems, uses '_copy_file_contents()' to copy file contents. Return a tuple (dest_name, copied): 'dest_name' is the actual name of the output file, and 'copied' is true if the file was copied (or would have been copied, if 'dry_run' true). i(unewer(uST_ATIMEuST_MTIMEuST_MODEuS_IMODEu4can't copy '%s': doesn't exist or not a regular fileiu"not copying %s (output up-to-date)u&invalid value '%s' for 'link' argumentu %s %s -> %suhardusym(udistutils.dep_utilunewerustatuST_ATIMEuST_MTIMEuST_MODEuS_IMODEuosupathuisfileuDistutilsFileErroruisdirujoinubasenameudirnameulogudebugu _copy_actionuKeyErroru ValueErroruinfouexistsusamefileulinkusymlinku_copy_file_contentsuutimeuchmod(usrcudstu preserve_modeupreserve_timesuupdateulinkuverboseudry_rununeweruST_ATIMEuST_MTIMEuST_MODEuS_IMODEudiruactionust((u8/opt/alt/python33/lib64/python3.3/distutils/file_util.pyu copy_fileCsJ "$    $  ' '  ! u copy_filec(Cs(ddlm}m}m}m}m}ddl} |dkrVtjd||ƒn|r`|S||ƒst d|ƒ‚n||ƒr©t j j |||ƒƒ}n%||ƒrÎt d||fƒ‚n|||ƒƒsùt d||fƒ‚nd } yt j||ƒWnet jk rz} zB| \} } | | jkrOd } nt d ||| fƒ‚WYdd} ~ XnX| r$t||d |ƒyt j|ƒWq$t jk r } zV| \} } yt j|ƒWnt jk rñYnXt d |||| fƒ‚WYdd} ~ Xq$Xn|S(u%Move a file 'src' to 'dst'. If 'dst' is a directory, the file will be moved into it with the same name; otherwise, 'src' is just renamed to 'dst'. Return the new full name of the file. Handles cross-device moves on Unix using 'copy_file()'. What about other systems??? i(uexistsuisfileuisdirubasenameudirnameNiumoving %s -> %su#can't move '%s': not a regular fileu0can't move '%s': destination '%s' already existsu2can't move '%s': destination '%s' not a valid pathucouldn't move '%s' to '%s': %suverboseuAcouldn't move '%s' to '%s' by copy/delete: delete '%s' failed: %sFT(uos.pathuexistsuisfileuisdirubasenameudirnameuerrnouloguinfouDistutilsFileErroruosupathujoinuFalseurenameuerroruEXDEVuTrueu copy_fileuunlink(usrcudstuverboseudry_runuexistsuisfileuisdirubasenameudirnameuerrnoucopy_itueunumumsg((u8/opt/alt/python33/lib64/python3.3/distutils/file_util.pyu move_filežsR (       ) ,u move_filec CsGt|dƒ}z&x|D]}|j|dƒqWWd|jƒXdS(u{Create a file with the specified name and write 'contents' (a sequence of strings without line terminators) to it. uwu N(uopenuwriteuclose(ufilenameucontentsufuline((u8/opt/alt/python33/lib64/python3.3/distutils/file_util.pyu write_fileÝs  u write_filei@( u__doc__uosudistutils.errorsuDistutilsFileErroru distutilsuloguNoneu _copy_actionu_copy_file_contentsu copy_fileu move_fileu write_file(((u8/opt/alt/python33/lib64/python3.3/distutils/file_util.pyus   3 [=