44 dircmp
55
66Functions:
7- cmp(f1, f2, shallow=1, use_statcache=0 ) -> int
7+ cmp(f1, f2, shallow=1) -> int
88 cmpfiles(a, b, common) -> ([], [], [])
99
1010"""
1111
1212import os
1313import stat
14+ import warnings
1415
1516__all__ = ["cmp" ,"dircmp" ,"cmpfiles" ]
1617
1718_cache = {}
1819BUFSIZE = 8 * 1024
1920
20- def cmp (f1 , f2 , shallow = 1 , use_statcache = 0 ):
21+ def cmp (f1 , f2 , shallow = 1 , use_statcache = None ):
2122 """Compare two files.
2223
2324 Arguments:
@@ -39,6 +40,10 @@ def cmp(f1, f2, shallow=1, use_statcache=0):
3940 with a cache invalidation mechanism relying on stale signatures.
4041
4142 """
43+ if use_statcache is not None :
44+ warnings .warn ("use_statcache argument is deprecated" ,
45+ DeprecationWarning )
46+
4247 s1 = _sig (os .stat (f1 ))
4348 s2 = _sig (os .stat (f2 ))
4449 if s1 [0 ] != stat .S_IFREG or s2 [0 ] != stat .S_IFREG :
@@ -261,7 +266,7 @@ def report_full_closure(self): # Report on self and subdirs recursively
261266 sd .report_full_closure ()
262267
263268
264- def cmpfiles (a , b , common , shallow = 1 , use_statcache = 0 ):
269+ def cmpfiles (a , b , common , shallow = 1 , use_statcache = None ):
265270 """Compare common files in two directories.
266271
267272 a, b -- directory names
@@ -275,6 +280,9 @@ def cmpfiles(a, b, common, shallow=1, use_statcache=0):
275280 filenames that aren't regular files.
276281
277282 """
283+ if use_statcache is not None :
284+ warnings .warn ("use_statcache argument is deprecated" ,
285+ DeprecationWarning )
278286 res = ([], [], [])
279287 for x in common :
280288 ax = os .path .join (a , x )
@@ -312,7 +320,7 @@ def demo():
312320 import getopt
313321 options , args = getopt .getopt (sys .argv [1 :], 'r' )
314322 if len (args ) != 2 :
315- raise getopt .error , 'need exactly two args'
323+ raise getopt .GetoptError ( 'need exactly two args' , None )
316324 dd = dircmp (args [0 ], args [1 ])
317325 if ('-r' , '' ) in options :
318326 dd .report_full_closure ()
0 commit comments