diff options
author | Guido van Rossum <guido@python.org> | 1992-12-14 12:57:56 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1992-12-14 12:57:56 (GMT) |
commit | 89a78697b86782a08be54269b9a7f55d4137d184 (patch) | |
tree | c93404611fb1495f466ccd5695b8e80cfab870a1 /Lib/dircmp.py | |
parent | a8993cfe16a04c612da72f72181ac63c6f858224 (diff) | |
download | cpython-89a78697b86782a08be54269b9a7f55d4137d184.zip cpython-89a78697b86782a08be54269b9a7f55d4137d184.tar.gz cpython-89a78697b86782a08be54269b9a7f55d4137d184.tar.bz2 |
* Got entirely rid of path.py.
* Many modules: fixes for new, stricter, argument passing rules
(most changes were automatic ones -- not all of this is tested!).
* gwin.py: now uses mainloop.py for its main loop and window admin.
* mainloop.py: always call dispatch() with event as a tuple!
* Fix bug in pdb's 'clear' command -- don't set the bpt but clear it!
Diffstat (limited to 'Lib/dircmp.py')
-rw-r--r-- | Lib/dircmp.py | 158 |
1 files changed, 79 insertions, 79 deletions
diff --git a/Lib/dircmp.py b/Lib/dircmp.py index cbbce1b..1227aa7 100644 --- a/Lib/dircmp.py +++ b/Lib/dircmp.py @@ -13,46 +13,46 @@ from stat import * # class dircmp: # - def new(dd, (a, b)): # Initialize - dd.a = a - dd.b = b - # Properties that caller may change before calling dd.run(): - dd.hide = [os.curdir, os.pardir] # Names never to be shown - dd.ignore = ['RCS', 'tags'] # Names ignored in comparison + def new(self, a, b): # Initialize + self.a = a + self.b = b + # Properties that caller may change before calling self.run(): + self.hide = [os.curdir, os.pardir] # Names never to be shown + self.ignore = ['RCS', 'tags'] # Names ignored in comparison # - return dd + return self # - def run(dd): # Compare everything except common subdirectories - dd.a_list = filter(dircache.listdir(dd.a), dd.hide) - dd.b_list = filter(dircache.listdir(dd.b), dd.hide) - dd.a_list.sort() - dd.b_list.sort() - dd.phase1() - dd.phase2() - dd.phase3() + def run(self): # Compare everything except common subdirectories + self.a_list = filter(dircache.listdir(self.a), self.hide) + self.b_list = filter(dircache.listdir(self.b), self.hide) + self.a_list.sort() + self.b_list.sort() + self.phase1() + self.phase2() + self.phase3() # - def phase1(dd): # Compute common names - dd.a_only = [] - dd.common = [] - for x in dd.a_list: - if x in dd.b_list: - dd.common.append(x) + def phase1(self): # Compute common names + self.a_only = [] + self.common = [] + for x in self.a_list: + if x in self.b_list: + self.common.append(x) else: - dd.a_only.append(x) + self.a_only.append(x) # - dd.b_only = [] - for x in dd.b_list: - if x not in dd.common: - dd.b_only.append(x) + self.b_only = [] + for x in self.b_list: + if x not in self.common: + self.b_only.append(x) # - def phase2(dd): # Distinguish files, directories, funnies - dd.common_dirs = [] - dd.common_files = [] - dd.common_funny = [] + def phase2(self): # Distinguish files, directories, funnies + self.common_dirs = [] + self.common_files = [] + self.common_funny = [] # - for x in dd.common: - a_path = os.path.join(dd.a, x) - b_path = os.path.join(dd.b, x) + for x in self.common: + a_path = os.path.join(self.a, x) + b_path = os.path.join(self.b, x) # ok = 1 try: @@ -70,74 +70,74 @@ class dircmp: a_type = S_IFMT(a_stat[ST_MODE]) b_type = S_IFMT(b_stat[ST_MODE]) if a_type <> b_type: - dd.common_funny.append(x) + self.common_funny.append(x) elif S_ISDIR(a_type): - dd.common_dirs.append(x) + self.common_dirs.append(x) elif S_ISREG(a_type): - dd.common_files.append(x) + self.common_files.append(x) else: - dd.common_funny.append(x) + self.common_funny.append(x) else: - dd.common_funny.append(x) + self.common_funny.append(x) # - def phase3(dd): # Find out differences between common files - xx = cmpfiles(dd.a, dd.b, dd.common_files) - dd.same_files, dd.diff_files, dd.funny_files = xx + def phase3(self): # Find out differences between common files + xx = cmpfiles(self.a, self.b, self.common_files) + self.same_files, self.diff_files, self.funny_files = xx # - def phase4(dd): # Find out differences between common subdirectories + def phase4(self): # Find out differences between common subdirectories # A new dircmp 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 - dd.subdirs = {} - for x in dd.common_dirs: - a_x = os.path.join(dd.a, x) - b_x = os.path.join(dd.b, x) - dd.subdirs[x] = newdd = dircmp().new(a_x, b_x) - newdd.hide = dd.hide - newdd.ignore = dd.ignore + self.subdirs = {} + for x in self.common_dirs: + a_x = os.path.join(self.a, x) + b_x = os.path.join(self.b, x) + self.subdirs[x] = newdd = dircmp().new(a_x, b_x) + newdd.hide = self.hide + newdd.ignore = self.ignore newdd.run() # - def phase4_closure(dd): # Recursively call phase4() on subdirectories - dd.phase4() - for x in dd.subdirs.keys(): - dd.subdirs[x].phase4_closure() + def phase4_closure(self): # Recursively call phase4() on subdirectories + self.phase4() + for x in self.subdirs.keys(): + self.subdirs[x].phase4_closure() # - def report(dd): # Print a report on the differences between a and b + def report(self): # Print a report on the differences between a and b # Assume that phases 1 to 3 have been executed # Output format is purposely lousy - print 'diff', dd.a, dd.b - if dd.a_only: - print 'Only in', dd.a, ':', dd.a_only - if dd.b_only: - print 'Only in', dd.b, ':', dd.b_only - if dd.same_files: - print 'Identical files :', dd.same_files - if dd.diff_files: - print 'Differing files :', dd.diff_files - if dd.funny_files: - print 'Trouble with common files :', dd.funny_files - if dd.common_dirs: - print 'Common subdirectories :', dd.common_dirs - if dd.common_funny: - print 'Common funny cases :', dd.common_funny + print 'diff', self.a, self.b + if self.a_only: + print 'Only in', self.a, ':', self.a_only + if self.b_only: + print 'Only in', self.b, ':', self.b_only + if self.same_files: + print 'Identical files :', self.same_files + if self.diff_files: + print 'Differing files :', self.diff_files + if self.funny_files: + print 'Trouble with common files :', self.funny_files + if self.common_dirs: + print 'Common subdirectories :', self.common_dirs + if self.common_funny: + print 'Common funny cases :', self.common_funny # - def report_closure(dd): # Print reports on dd and on subdirs + def report_closure(self): # Print reports on self and on subdirs # If phase 4 hasn't been done, no subdir reports are printed - dd.report() + self.report() try: - x = dd.subdirs + x = self.subdirs except AttributeError: return # No subdirectories computed - for x in dd.subdirs.keys(): + for x in self.subdirs.keys(): print - dd.subdirs[x].report_closure() + self.subdirs[x].report_closure() # - def report_phase4_closure(dd): # Report and do phase 4 recursively - dd.report() - dd.phase4() - for x in dd.subdirs.keys(): + def report_phase4_closure(self): # Report and do phase 4 recursively + self.report() + self.phase4() + for x in self.subdirs.keys(): print - dd.subdirs[x].report_phase4_closure() + self.subdirs[x].report_phase4_closure() # Compare common files in two directories. |