8000 shutil: Implement copyfileobj(). · micropython/micropython-lib@a03e185 · GitHub
[go: up one dir, main page]

Skip to content

Commit a03e185

Browse files
author
Paul Sokolovsky
committed
shutil: Implement copyfileobj().
1 parent c89a9fd commit a03e185

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

shutil/shutil.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,15 @@ def rmtree(top):
77
for f in files:
88
os.unlink(path + "/" + f)
99
os.rmdir(path)
10+
11+
def copyfileobj(src, dest, length=512):
12+
buf = bytearray(length)
13+
while True:
14+
sz = src.readinto(buf)
15+
if not sz:
16+
break
17+
if sz == length:
18+
dest.write(buf)
19+
else:
20+
b = memoryview(buf)[:sz]
21+
dest.write(b)

0 commit comments

Comments
 (0)
0