mirror of
https://github.com/python/cpython.git
synced 2025-08-26 03:34:43 +00:00
bpo-15450: Allow subclassing of dircmp (GH-23424) (#23424)
Co-authored-by: Chris Jerdonek <chris.jerdonek@gmail.com>
This commit is contained in:
parent
ff420f0e08
commit
2f2f9d0b5c
5 changed files with 60 additions and 13 deletions
|
@ -115,7 +115,9 @@ class dircmp:
|
|||
same_files: list of identical files.
|
||||
diff_files: list of filenames which differ.
|
||||
funny_files: list of files which could not be compared.
|
||||
subdirs: a dictionary of dircmp objects, keyed by names in common_dirs.
|
||||
subdirs: a dictionary of dircmp instances (or MyDirCmp instances if this
|
||||
object is of type MyDirCmp, a subclass of dircmp), keyed by names
|
||||
in common_dirs.
|
||||
"""
|
||||
|
||||
def __init__(self, a, b, ignore=None, hide=None): # Initialize
|
||||
|
@ -185,14 +187,15 @@ class dircmp:
|
|||
self.same_files, self.diff_files, self.funny_files = xx
|
||||
|
||||
def phase4(self): # Find out differences between common subdirectories
|
||||
# A new dircmp object is created for each common subdirectory,
|
||||
# A new dircmp (or MyDirCmp if dircmp was subclassed) object is created
|
||||
# for each common subdirectory,
|
||||
# these are stored in a dictionary indexed by filename.
|
||||
# The hide and ignore properties are inherited from the parent
|
||||
self.subdirs = {}
|
||||
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] = self.__class__(a_x, b_x, self.ignore, self.hide)
|
||||
|
||||
def phase4_closure(self): # Recursively call phase4() on subdirectories
|
||||
self.phase4()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue