Message61252
It would be nice to be able to choose which of the copy
functions is used in copytree. I am currently working
on a project where I would like to copy a tree, but I
do not want to preserve permissions so I'd like
copytree to use copyfile instead of copy2.
Here is a snippet of copytree from shutil.py that I
modified by adding a func parameter and defaulting it
to copy2.
def copytree(src, dst, symlinks=False, func=copy2):
.
.
.
try:
if symlinks and os.path.islink(srcname):
linkto = os.readlink(srcname)
os.symlink(linkto, dstname)
elif os.path.isdir(srcname):
copytree(srcname, dstname, symlinks)
else:
func(srcname, dstname)
.
.
.
|
|
Date |
User |
Action |
Args |
2008-01-20 09:59:50 | admin | link | issue1540112 messages |
2008-01-20 09:59:50 | admin | create | |
|