shutil: Implement copyfileobj().

pull/20/merge
Paul Sokolovsky 2015-01-29 00:14:50 +02:00
rodzic c89a9fd7b1
commit a03e185f0d
1 zmienionych plików z 12 dodań i 0 usunięć

Wyświetl plik

@ -7,3 +7,15 @@ def rmtree(top):
for f in files:
os.unlink(path + "/" + f)
os.rmdir(path)
def copyfileobj(src, dest, length=512):
buf = bytearray(length)
while True:
sz = src.readinto(buf)
if not sz:
break
if sz == length:
dest.write(buf)
else:
b = memoryview(buf)[:sz]
dest.write(b)