[Python-checkins] CVS: python/dist/src/Lib shutil.py,1.16,1.17
Greg Stein
python-dev@python.org
Wed, 12 Jul 2000 02:55:33 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory slayer.i.sourceforge.net:/tmp/cvs-serv15196
Modified Files:
shutil.py
Log Message:
apply patch #100868 from Moshe Zadka:
refactor the copying of file data. new: shutil.copyfileobj(fsrc, fdst)
Index: shutil.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/shutil.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** shutil.py 2000/04/07 14:34:50 1.16
--- shutil.py 2000/07/12 09:55:30 1.17
***************
*** 10,13 ****
--- 10,22 ----
+ def copyfileobj(fsrc, fdst, length=16*1024):
+ """copy data from file-like object fsrc to file-like object fdst"""
+ while 1:
+ buf = fsrc.read(length)
+ if not buf:
+ break
+ fdst.write(buf)
+
+
def copyfile(src, dst):
"""Copy data from src to dst"""
***************
*** 17,25 ****
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:
--- 26,30 ----
fsrc = open(src, 'rb')
fdst = open(dst, 'wb')
! copyfileobj(fsrc, fdst)
finally:
if fdst: