diff -r 01da7bf11ca1 Doc/library/filecmp.rst --- a/Doc/library/filecmp.rst Fri Jun 14 15:04:26 2013 -0400 +++ b/Doc/library/filecmp.rst Fri Jun 14 17:16:50 2013 -0400 @@ -53,15 +53,15 @@ The :class:`dircmp` class ------------------------- -.. class:: dircmp(a, b, ignore=None, hide=None) +.. class:: dircmp(a, b, ignore=None, hide=None, shallow=True) Construct a new directory comparison object, to compare the directories *a* and *b*. *ignore* is a list of names to ignore, and defaults to :attr:`filecmp.DEFAULT_IGNORES`. *hide* is a list of names to hide, and defaults to ``[os.curdir, os.pardir]``. - The :class:`dircmp` class compares files by doing *shallow* comparisons - as described for :func:`filecmp.cmp`. + The *shallow* parameter has the same meaning and default value as for + :func:`filecmp.cmp`. The :class:`dircmp` class provides the following methods: diff -r 01da7bf11ca1 Lib/filecmp.py --- a/Lib/filecmp.py Fri Jun 14 15:04:26 2013 -0400 +++ b/Lib/filecmp.py Fri Jun 14 17:16:50 2013 -0400 @@ -81,12 +81,15 @@ class dircmp: """A class that manages the comparison of 2 directories. - dircmp(a, b, ignore=None, hide=None) + dircmp(a, b, ignore=None, hide=None, shallow=True) A and B are directories. IGNORE is a list of names to ignore, defaults to DEFAULT_IGNORES. HIDE is a list of names to hide, defaults to [os.curdir, os.pardir]. + SHALLOW specifies whether to just check the stat signature (do not read + the files). + defaults to True. High level usage: x = dircmp(dir1, dir2) @@ -112,7 +115,7 @@ subdirs: a dictionary of dircmp objects, keyed by names in common_dirs. """ - def __init__(self, a, b, ignore=None, hide=None): # Initialize + def __init__(self, a, b, ignore=None, hide=None, shallow=True): # Initialize self.left = a self.right = b if hide is None: @@ -123,6 +126,7 @@ self.ignore = DEFAULT_IGNORES else: self.ignore = ignore + self.shallow = shallow def phase0(self): # Compare everything except common subdirectories self.left_list = _filter(os.listdir(self.left), @@ -175,7 +179,7 @@ self.common_funny.append(x) def phase3(self): # Find out differences between common files - xx = cmpfiles(self.left, self.right, self.common_files) + xx = cmpfiles(self.left, self.right, self.common_files, self.shallow) self.same_files, self.diff_files, self.funny_files = xx def phase4(self): # Find out differences between common subdirectories @@ -186,7 +190,7 @@ for x in self.common_dirs: a_x = os.path.join(self.left, x) b_x = os.path.join(self.right, x) - self.subdirs[x] = dircmp(a_x, b_x, self.ignore, self.hide) + self.subdirs[x] = dircmp(a_x, b_x, self.ignore, self.hide, self.shallow) def phase4_closure(self): # Recursively call phase4() on subdirectories self.phase4()