diff options
| author | Skip Montanaro <[email protected]> | 2021-02-16 20:14:16 -0600 |
|---|---|---|
| committer | Skip Montanaro <[email protected]> | 2021-02-16 20:14:16 -0600 |
| commit | c2587c76f1b416cdbecb979e54941933246bf856 (patch) | |
| tree | bb61ee9128075ce22af4eafa232f13c2e5a07896 /lib/shutil.py | |
| parent | d90761a005b24018ae237bf551515772a1de656f (diff) | |
| download | python-0.9.1-patched-QoL-c2587c76f1b416cdbecb979e54941933246bf856.tar.xz python-0.9.1-patched-QoL-c2587c76f1b416cdbecb979e54941933246bf856.zip | |
starting over
Diffstat (limited to 'lib/shutil.py')
| -rw-r--r-- | lib/shutil.py | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/lib/shutil.py b/lib/shutil.py index c01d889..cf63396 100644 --- a/lib/shutil.py +++ b/lib/shutil.py @@ -3,68 +3,68 @@ import posix import path -MODEBITS = 010000 # Lower 12 mode bits +MODEBITS = 010000 # Lower 12 mode bits # Change this to 01000 (9 mode bits) to avoid copying setuid etc. # Copy data from src to dst # def copyfile(src, dst): - fsrc = open(src, 'r') - fdst = open(dst, 'w') - while 1: - buf = fsrc.read(16*1024) - if not buf: break - fdst.write(buf) + fsrc = open(src, 'r') + fdst = open(dst, 'w') + while 1: + buf = fsrc.read(16*1024) + if not buf: break + fdst.write(buf) # Copy mode bits from src to dst # def copymode(src, dst): - st = posix.stat(src) - mode = divmod(st[0], MODEBITS)[1] - posix.chmod(dst, mode) + st = posix.stat(src) + mode = divmod(st[0], MODEBITS)[1] + posix.chmod(dst, mode) # Copy all stat info (mode bits, atime and mtime) from src to dst # def copystat(src, dst): - st = posix.stat(src) - mode = divmod(st[0], MODEBITS)[1] - posix.chmod(dst, mode) - posix.utimes(dst, st[7:9]) + st = posix.stat(src) + mode = divmod(st[0], MODEBITS)[1] + posix.chmod(dst, mode) + posix.utimes(dst, st[7:9]) # Copy data and mode bits ("cp src dst") # def copy(src, dst): - copyfile(src, dst) - copymode(src, dst) + copyfile(src, dst) + copymode(src, dst) # Copy data and all stat info ("cp -p src dst") # def copy2(src, dst): - copyfile(src, dst) - copystat(src, dst) + copyfile(src, dst) + copystat(src, dst) # Recursively copy a directory tree. # The destination must not already exist. # def copytree(src, dst): - names = posix.listdir(src) - posix.mkdir(dst, 0777) - dot_dotdot = '.', '..' - for name in names: - if name not in dot_dotdot: - srcname = path.cat(src, name) - dstname = path.cat(dst, name) - #print 'Copying', srcname, 'to', dstname - try: - #if path.islink(srcname): - # linkto = posix.readlink(srcname) - # posix.symlink(linkto, dstname) - #elif path.isdir(srcname): - if path.isdir(srcname): - copytree(srcname, dstname) - else: - copy2(srcname, dstname) - # XXX What about devices, sockets etc.? - except posix.error, why: - print 'Could not copy', srcname, 'to', dstname, - print '(', why[1], ')' + names = posix.listdir(src) + posix.mkdir(dst, 0777) + dot_dotdot = '.', '..' + for name in names: + if name not in dot_dotdot: + srcname = path.cat(src, name) + dstname = path.cat(dst, name) + #print 'Copying', srcname, 'to', dstname + try: + #if path.islink(srcname): + # linkto = posix.readlink(srcname) + # posix.symlink(linkto, dstname) + #elif path.isdir(srcname): + if path.isdir(srcname): + copytree(srcname, dstname) + else: + copy2(srcname, dstname) + # XXX What about devices, sockets etc.? + except posix.error, why: + print 'Could not copy', srcname, 'to', dstname, + print '(', why[1], ')' |
