[Patches] filecmp.py: new function to compare file _objects_
gerrit@nl.linux.org
gerrit@nl.linux.org
Wed, 1 Mar 2000 14:56:11 +0100
--u3/rZRmxL6MmkK24
Content-Type: text/plain; charset=us-ascii
Hello,
I changed the filecmp.py module a bit to put the comparing of the
file objects in a seperate function 'cmpfp', which can be used by
the programmer. I needed this functionality for comparing two
cStringIO file objects.
--
Comparison Python GUI's: http://www.nl.linux.org/~gerrit/gui.html
Please comment!
--u3/rZRmxL6MmkK24
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="filecmp.py.diff"
*** /tmp/filecmp.py Tue Feb 29 10:33:36 2000
--- filecmp.py Tue Feb 29 10:50:22 2000
***************
*** 51,57 ****
def _do_cmp(f1, f2):
bufsize = BUFSIZE
fp1 , fp2 = open(f1, 'rb'), open(f2, 'rb')
while 1:
! b1, b2 = fp1.read(bufsize), fp2.read(bufsize)
if b1!=b2: return 0
if not b1: return 1
--- 51,60 ----
def _do_cmp(f1, f2):
bufsize = BUFSIZE
fp1 , fp2 = open(f1, 'rb'), open(f2, 'rb')
+ return cmpfp(fp1, fp2)
+
+ def cmpfp(fp1, fp2):
while 1:
! b1, b2 = fp1.read(BUFSIZE), fp2.read(BUFSIZE)
if b1!=b2: return 0
if not b1: return 1
--u3/rZRmxL6MmkK24--