mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Mass check-in after untabifying all files that need it.
This commit is contained in:
parent
9ea7024754
commit
45e2fbc2e7
50 changed files with 5249 additions and 5249 deletions
|
@ -13,18 +13,18 @@ def copyfile(src, dst):
|
|||
fsrc = None
|
||||
fdst = None
|
||||
try:
|
||||
fsrc = open(src, 'rb')
|
||||
fdst = open(dst, 'wb')
|
||||
while 1:
|
||||
buf = fsrc.read(16*1024)
|
||||
if not buf:
|
||||
break
|
||||
fdst.write(buf)
|
||||
fsrc = open(src, 'rb')
|
||||
fdst = open(dst, 'wb')
|
||||
while 1:
|
||||
buf = fsrc.read(16*1024)
|
||||
if not buf:
|
||||
break
|
||||
fdst.write(buf)
|
||||
finally:
|
||||
if fdst:
|
||||
fdst.close()
|
||||
if fsrc:
|
||||
fsrc.close()
|
||||
if fdst:
|
||||
fdst.close()
|
||||
if fsrc:
|
||||
fsrc.close()
|
||||
|
||||
def copymode(src, dst):
|
||||
"""Copy mode bits from src to dst"""
|
||||
|
@ -47,7 +47,7 @@ def copy(src, dst):
|
|||
|
||||
"""
|
||||
if os.path.isdir(dst):
|
||||
dst = os.path.join(dst, os.path.basename(src))
|
||||
dst = os.path.join(dst, os.path.basename(src))
|
||||
copyfile(src, dst)
|
||||
copymode(src, dst)
|
||||
|
||||
|
@ -58,7 +58,7 @@ def copy2(src, dst):
|
|||
|
||||
"""
|
||||
if os.path.isdir(dst):
|
||||
dst = os.path.join(dst, os.path.basename(src))
|
||||
dst = os.path.join(dst, os.path.basename(src))
|
||||
copyfile(src, dst)
|
||||
copystat(src, dst)
|
||||
|
||||
|
@ -80,19 +80,19 @@ def copytree(src, dst, symlinks=0):
|
|||
names = os.listdir(src)
|
||||
os.mkdir(dst)
|
||||
for name in names:
|
||||
srcname = os.path.join(src, name)
|
||||
dstname = os.path.join(dst, name)
|
||||
try:
|
||||
if symlinks and os.path.islink(srcname):
|
||||
linkto = os.readlink(srcname)
|
||||
os.symlink(linkto, dstname)
|
||||
elif os.path.isdir(srcname):
|
||||
copytree(srcname, dstname)
|
||||
else:
|
||||
copy2(srcname, dstname)
|
||||
# XXX What about devices, sockets etc.?
|
||||
except (IOError, os.error), why:
|
||||
print "Can't copy %s to %s: %s" % (`srcname`, `dstname`, str(why))
|
||||
srcname = os.path.join(src, name)
|
||||
dstname = os.path.join(dst, name)
|
||||
try:
|
||||
if symlinks and os.path.islink(srcname):
|
||||
linkto = os.readlink(srcname)
|
||||
os.symlink(linkto, dstname)
|
||||
elif os.path.isdir(srcname):
|
||||
copytree(srcname, dstname)
|
||||
else:
|
||||
copy2(srcname, dstname)
|
||||
# XXX What about devices, sockets etc.?
|
||||
except (IOError, os.error), why:
|
||||
print "Can't copy %s to %s: %s" % (`srcname`, `dstname`, str(why))
|
||||
|
||||
def rmtree(path, ignore_errors=0, onerror=None):
|
||||
"""Recursively delete a directory tree.
|
||||
|
@ -105,23 +105,23 @@ def rmtree(path, ignore_errors=0, onerror=None):
|
|||
cmdtuples = []
|
||||
_build_cmdtuple(path, cmdtuples)
|
||||
for cmd in cmdtuples:
|
||||
try:
|
||||
apply(cmd[0], (cmd[1],))
|
||||
except:
|
||||
exc = sys.exc_info()
|
||||
if ignore_errors:
|
||||
pass
|
||||
elif onerror:
|
||||
onerror(cmd[0], cmd[1], exc)
|
||||
else:
|
||||
raise exc[0], (exc[1][0], exc[1][1] + ' removing '+cmd[1])
|
||||
try:
|
||||
apply(cmd[0], (cmd[1],))
|
||||
except:
|
||||
exc = sys.exc_info()
|
||||
if ignore_errors:
|
||||
pass
|
||||
elif onerror:
|
||||
onerror(cmd[0], cmd[1], exc)
|
||||
else:
|
||||
raise exc[0], (exc[1][0], exc[1][1] + ' removing '+cmd[1])
|
||||
|
||||
# Helper for rmtree()
|
||||
def _build_cmdtuple(path, cmdtuples):
|
||||
for f in os.listdir(path):
|
||||
real_f = os.path.join(path,f)
|
||||
if os.path.isdir(real_f) and not os.path.islink(real_f):
|
||||
_build_cmdtuple(real_f, cmdtuples)
|
||||
else:
|
||||
cmdtuples.append(os.remove, real_f)
|
||||
real_f = os.path.join(path,f)
|
||||
if os.path.isdir(real_f) and not os.path.islink(real_f):
|
||||
_build_cmdtuple(real_f, cmdtuples)
|
||||
else:
|
||||
cmdtuples.append(os.remove, real_f)
|
||||
cmdtuples.append(os.rmdir, path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue