Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 1 | """Utilities for comparing files and directories. |
Guido van Rossum | 2d72687 | 1999-10-26 14:02:01 +0000 | [diff] [blame] | 2 | |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 3 | Classes: |
| 4 | dircmp |
| 5 | |
| 6 | Functions: |
Georg Brandl | 55689c9 | 2009-05-17 12:19:44 +0000 | [diff] [blame] | 7 | cmp(f1, f2, shallow=True) -> int |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 8 | cmpfiles(a, b, common) -> ([], [], []) |
| 9 | |
| 10 | """ |
| 11 | |
| 12 | import os |
| 13 | import stat |
Raymond Hettinger | 736c0ab | 2008-03-13 02:09:15 +0000 | [diff] [blame] | 14 | from itertools import filterfalse |
Guido van Rossum | 2d72687 | 1999-10-26 14:02:01 +0000 | [diff] [blame] | 15 | |
Georg Brandl | 55689c9 | 2009-05-17 12:19:44 +0000 | [diff] [blame] | 16 | __all__ = ["cmp", "dircmp", "cmpfiles"] |
Skip Montanaro | eccd02a | 2001-01-20 23:34:12 +0000 | [diff] [blame] | 17 | |
Guido van Rossum | 2d72687 | 1999-10-26 14:02:01 +0000 | [diff] [blame] | 18 | _cache = {} |
Georg Brandl | 55689c9 | 2009-05-17 12:19:44 +0000 | [diff] [blame] | 19 | BUFSIZE = 8*1024 |
Guido van Rossum | 2d72687 | 1999-10-26 14:02:01 +0000 | [diff] [blame] | 20 | |
Georg Brandl | 55689c9 | 2009-05-17 12:19:44 +0000 | [diff] [blame] | 21 | def cmp(f1, f2, shallow=True): |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 22 | """Compare two files. |
Guido van Rossum | 2d72687 | 1999-10-26 14:02:01 +0000 | [diff] [blame] | 23 | |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 24 | Arguments: |
Guido van Rossum | 2d72687 | 1999-10-26 14:02:01 +0000 | [diff] [blame] | 25 | |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 26 | f1 -- First file name |
Guido van Rossum | 2d72687 | 1999-10-26 14:02:01 +0000 | [diff] [blame] | 27 | |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 28 | f2 -- Second file name |
Guido van Rossum | 2d72687 | 1999-10-26 14:02:01 +0000 | [diff] [blame] | 29 | |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 30 | shallow -- Just check stat signature (do not read the files). |
| 31 | defaults to 1. |
Guido van Rossum | 2d72687 | 1999-10-26 14:02:01 +0000 | [diff] [blame] | 32 | |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 33 | Return value: |
Guido van Rossum | 2d72687 | 1999-10-26 14:02:01 +0000 | [diff] [blame] | 34 | |
Tim Peters | bc0e910 | 2002-04-04 22:55:58 +0000 | [diff] [blame] | 35 | True if the files are the same, False otherwise. |
Guido van Rossum | 2d72687 | 1999-10-26 14:02:01 +0000 | [diff] [blame] | 36 | |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 37 | This function uses a cache for past comparisons and the results, |
| 38 | with a cache invalidation mechanism relying on stale signatures. |
Guido van Rossum | 2d72687 | 1999-10-26 14:02:01 +0000 | [diff] [blame] | 39 | |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 40 | """ |
Andrew M. Kuchling | 83e879d | 2003-02-06 19:38:45 +0000 | [diff] [blame] | 41 | |
Andrew M. Kuchling | 8eb4044 | 2003-02-06 17:50:01 +0000 | [diff] [blame] | 42 | s1 = _sig(os.stat(f1)) |
| 43 | s2 = _sig(os.stat(f2)) |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 44 | if s1[0] != stat.S_IFREG or s2[0] != stat.S_IFREG: |
Tim Peters | bc0e910 | 2002-04-04 22:55:58 +0000 | [diff] [blame] | 45 | return False |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 46 | if shallow and s1 == s2: |
Tim Peters | bc0e910 | 2002-04-04 22:55:58 +0000 | [diff] [blame] | 47 | return True |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 48 | if s1[1] != s2[1]: |
Tim Peters | bc0e910 | 2002-04-04 22:55:58 +0000 | [diff] [blame] | 49 | return False |
Guido van Rossum | 2d72687 | 1999-10-26 14:02:01 +0000 | [diff] [blame] | 50 | |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 51 | result = _cache.get((f1, f2)) |
| 52 | if result and (s1, s2) == result[:2]: |
| 53 | return result[2] |
| 54 | outcome = _do_cmp(f1, f2) |
| 55 | _cache[f1, f2] = s1, s2, outcome |
| 56 | return outcome |
Guido van Rossum | 2d72687 | 1999-10-26 14:02:01 +0000 | [diff] [blame] | 57 | |
| 58 | def _sig(st): |
Raymond Hettinger | 32200ae | 2002-06-01 19:51:15 +0000 | [diff] [blame] | 59 | return (stat.S_IFMT(st.st_mode), |
| 60 | st.st_size, |
| 61 | st.st_mtime) |
Guido van Rossum | 2d72687 | 1999-10-26 14:02:01 +0000 | [diff] [blame] | 62 | |
| 63 | def _do_cmp(f1, f2): |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 64 | bufsize = BUFSIZE |
Raymond Hettinger | 686057b | 2009-06-04 00:11:54 +0000 | [diff] [blame] | 65 | with open(f1, 'rb') as fp1, open(f2, 'rb') as fp2: |
Benjamin Peterson | f07d002 | 2009-03-21 17:31:58 +0000 | [diff] [blame] | 66 | while True: |
| 67 | b1 = fp1.read(bufsize) |
| 68 | b2 = fp2.read(bufsize) |
| 69 | if b1 != b2: |
| 70 | return False |
| 71 | if not b1: |
| 72 | return True |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 73 | |
| 74 | # Directory comparison class. |
| 75 | # |
| 76 | class dircmp: |
| 77 | """A class that manages the comparison of 2 directories. |
| 78 | |
Georg Brandl | 55689c9 | 2009-05-17 12:19:44 +0000 | [diff] [blame] | 79 | dircmp(a, b, ignore=None, hide=None) |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 80 | A and B are directories. |
| 81 | IGNORE is a list of names to ignore, |
| 82 | defaults to ['RCS', 'CVS', 'tags']. |
| 83 | HIDE is a list of names to hide, |
| 84 | defaults to [os.curdir, os.pardir]. |
| 85 | |
| 86 | High level usage: |
| 87 | x = dircmp(dir1, dir2) |
| 88 | x.report() -> prints a report on the differences between dir1 and dir2 |
| 89 | or |
| 90 | x.report_partial_closure() -> prints report on differences between dir1 |
| 91 | and dir2, and reports on common immediate subdirectories. |
| 92 | x.report_full_closure() -> like report_partial_closure, |
| 93 | but fully recursive. |
| 94 | |
| 95 | Attributes: |
| 96 | left_list, right_list: The files in dir1 and dir2, |
| 97 | filtered by hide and ignore. |
| 98 | common: a list of names in both dir1 and dir2. |
| 99 | left_only, right_only: names only in dir1, dir2. |
| 100 | common_dirs: subdirectories in both dir1 and dir2. |
| 101 | common_files: files in both dir1 and dir2. |
| 102 | common_funny: names in both dir1 and dir2 where the type differs between |
| 103 | dir1 and dir2, or the name is not stat-able. |
| 104 | same_files: list of identical files. |
| 105 | diff_files: list of filenames which differ. |
| 106 | funny_files: list of files which could not be compared. |
| 107 | subdirs: a dictionary of dircmp objects, keyed by names in common_dirs. |
| 108 | """ |
| 109 | |
| 110 | def __init__(self, a, b, ignore=None, hide=None): # Initialize |
| 111 | self.left = a |
| 112 | self.right = b |
| 113 | if hide is None: |
| 114 | self.hide = [os.curdir, os.pardir] # Names never to be shown |
| 115 | else: |
| 116 | self.hide = hide |
| 117 | if ignore is None: |
| 118 | self.ignore = ['RCS', 'CVS', 'tags'] # Names ignored in comparison |
| 119 | else: |
| 120 | self.ignore = ignore |
| 121 | |
| 122 | def phase0(self): # Compare everything except common subdirectories |
| 123 | self.left_list = _filter(os.listdir(self.left), |
| 124 | self.hide+self.ignore) |
| 125 | self.right_list = _filter(os.listdir(self.right), |
| 126 | self.hide+self.ignore) |
| 127 | self.left_list.sort() |
| 128 | self.right_list.sort() |
| 129 | |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 130 | def phase1(self): # Compute common names |
Raymond Hettinger | 736c0ab | 2008-03-13 02:09:15 +0000 | [diff] [blame] | 131 | a = dict(zip(map(os.path.normcase, self.left_list), self.left_list)) |
| 132 | b = dict(zip(map(os.path.normcase, self.right_list), self.right_list)) |
Raymond Hettinger | 17301e9 | 2008-03-13 00:19:26 +0000 | [diff] [blame] | 133 | self.common = list(map(a.__getitem__, filter(b.__contains__, a))) |
Raymond Hettinger | b0002d2 | 2008-03-13 01:41:43 +0000 | [diff] [blame] | 134 | self.left_only = list(map(a.__getitem__, filterfalse(b.__contains__, a))) |
| 135 | self.right_only = list(map(b.__getitem__, filterfalse(a.__contains__, b))) |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 136 | |
| 137 | def phase2(self): # Distinguish files, directories, funnies |
| 138 | self.common_dirs = [] |
| 139 | self.common_files = [] |
| 140 | self.common_funny = [] |
| 141 | |
| 142 | for x in self.common: |
| 143 | a_path = os.path.join(self.left, x) |
| 144 | b_path = os.path.join(self.right, x) |
| 145 | |
| 146 | ok = 1 |
| 147 | try: |
Andrew M. Kuchling | 8eb4044 | 2003-02-06 17:50:01 +0000 | [diff] [blame] | 148 | a_stat = os.stat(a_path) |
Guido van Rossum | b940e11 | 2007-01-10 16:19:56 +0000 | [diff] [blame] | 149 | except os.error as why: |
Georg Brandl | d11b68a | 2008-01-06 21:13:42 +0000 | [diff] [blame] | 150 | # print('Can\'t stat', a_path, ':', why.args[1]) |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 151 | ok = 0 |
| 152 | try: |
Andrew M. Kuchling | 8eb4044 | 2003-02-06 17:50:01 +0000 | [diff] [blame] | 153 | b_stat = os.stat(b_path) |
Guido van Rossum | b940e11 | 2007-01-10 16:19:56 +0000 | [diff] [blame] | 154 | except os.error as why: |
Georg Brandl | d11b68a | 2008-01-06 21:13:42 +0000 | [diff] [blame] | 155 | # print('Can\'t stat', b_path, ':', why.args[1]) |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 156 | ok = 0 |
| 157 | |
| 158 | if ok: |
Raymond Hettinger | 32200ae | 2002-06-01 19:51:15 +0000 | [diff] [blame] | 159 | a_type = stat.S_IFMT(a_stat.st_mode) |
| 160 | b_type = stat.S_IFMT(b_stat.st_mode) |
Fred Drake | 8152d32 | 2000-12-12 23:20:45 +0000 | [diff] [blame] | 161 | if a_type != b_type: |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 162 | self.common_funny.append(x) |
| 163 | elif stat.S_ISDIR(a_type): |
| 164 | self.common_dirs.append(x) |
| 165 | elif stat.S_ISREG(a_type): |
| 166 | self.common_files.append(x) |
| 167 | else: |
| 168 | self.common_funny.append(x) |
| 169 | else: |
| 170 | self.common_funny.append(x) |
| 171 | |
| 172 | def phase3(self): # Find out differences between common files |
| 173 | xx = cmpfiles(self.left, self.right, self.common_files) |
| 174 | self.same_files, self.diff_files, self.funny_files = xx |
| 175 | |
| 176 | def phase4(self): # Find out differences between common subdirectories |
| 177 | # A new dircmp object is created for each common subdirectory, |
| 178 | # these are stored in a dictionary indexed by filename. |
| 179 | # The hide and ignore properties are inherited from the parent |
| 180 | self.subdirs = {} |
| 181 | for x in self.common_dirs: |
| 182 | a_x = os.path.join(self.left, x) |
| 183 | b_x = os.path.join(self.right, x) |
| 184 | self.subdirs[x] = dircmp(a_x, b_x, self.ignore, self.hide) |
| 185 | |
| 186 | def phase4_closure(self): # Recursively call phase4() on subdirectories |
| 187 | self.phase4() |
Guido van Rossum | cc2b016 | 2007-02-11 06:12:03 +0000 | [diff] [blame] | 188 | for sd in self.subdirs.values(): |
Raymond Hettinger | e0d4972 | 2002-06-02 18:55:56 +0000 | [diff] [blame] | 189 | sd.phase4_closure() |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 190 | |
| 191 | def report(self): # Print a report on the differences between a and b |
| 192 | # Output format is purposely lousy |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 193 | print('diff', self.left, self.right) |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 194 | if self.left_only: |
| 195 | self.left_only.sort() |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 196 | print('Only in', self.left, ':', self.left_only) |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 197 | if self.right_only: |
| 198 | self.right_only.sort() |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 199 | print('Only in', self.right, ':', self.right_only) |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 200 | if self.same_files: |
| 201 | self.same_files.sort() |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 202 | print('Identical files :', self.same_files) |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 203 | if self.diff_files: |
| 204 | self.diff_files.sort() |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 205 | print('Differing files :', self.diff_files) |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 206 | if self.funny_files: |
| 207 | self.funny_files.sort() |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 208 | print('Trouble with common files :', self.funny_files) |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 209 | if self.common_dirs: |
| 210 | self.common_dirs.sort() |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 211 | print('Common subdirectories :', self.common_dirs) |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 212 | if self.common_funny: |
| 213 | self.common_funny.sort() |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 214 | print('Common funny cases :', self.common_funny) |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 215 | |
| 216 | def report_partial_closure(self): # Print reports on self and on subdirs |
| 217 | self.report() |
Guido van Rossum | cc2b016 | 2007-02-11 06:12:03 +0000 | [diff] [blame] | 218 | for sd in self.subdirs.values(): |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 219 | print() |
Raymond Hettinger | e0d4972 | 2002-06-02 18:55:56 +0000 | [diff] [blame] | 220 | sd.report() |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 221 | |
| 222 | def report_full_closure(self): # Report on self and subdirs recursively |
| 223 | self.report() |
Guido van Rossum | cc2b016 | 2007-02-11 06:12:03 +0000 | [diff] [blame] | 224 | for sd in self.subdirs.values(): |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 225 | print() |
Raymond Hettinger | e0d4972 | 2002-06-02 18:55:56 +0000 | [diff] [blame] | 226 | sd.report_full_closure() |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 227 | |
Raymond Hettinger | 05595e9 | 2003-02-27 00:05:31 +0000 | [diff] [blame] | 228 | methodmap = dict(subdirs=phase4, |
| 229 | same_files=phase3, diff_files=phase3, funny_files=phase3, |
| 230 | common_dirs = phase2, common_files=phase2, common_funny=phase2, |
| 231 | common=phase1, left_only=phase1, right_only=phase1, |
| 232 | left_list=phase0, right_list=phase0) |
| 233 | |
| 234 | def __getattr__(self, attr): |
| 235 | if attr not in self.methodmap: |
Collin Winter | ce36ad8 | 2007-08-30 01:19:48 +0000 | [diff] [blame] | 236 | raise AttributeError(attr) |
Raymond Hettinger | 05595e9 | 2003-02-27 00:05:31 +0000 | [diff] [blame] | 237 | self.methodmap[attr](self) |
| 238 | return getattr(self, attr) |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 239 | |
Georg Brandl | 55689c9 | 2009-05-17 12:19:44 +0000 | [diff] [blame] | 240 | def cmpfiles(a, b, common, shallow=True): |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 241 | """Compare common files in two directories. |
| 242 | |
Fred Drake | 2b0d98b | 2000-07-03 08:18:47 +0000 | [diff] [blame] | 243 | a, b -- directory names |
| 244 | common -- list of file names found in both directories |
| 245 | shallow -- if true, do comparison based solely on stat() information |
Fred Drake | 2b0d98b | 2000-07-03 08:18:47 +0000 | [diff] [blame] | 246 | |
| 247 | Returns a tuple of three lists: |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 248 | files that compare equal |
| 249 | files that are different |
Fred Drake | 2b0d98b | 2000-07-03 08:18:47 +0000 | [diff] [blame] | 250 | filenames that aren't regular files. |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 251 | |
Fred Drake | 2b0d98b | 2000-07-03 08:18:47 +0000 | [diff] [blame] | 252 | """ |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 253 | res = ([], [], []) |
| 254 | for x in common: |
Fred Drake | 2b0d98b | 2000-07-03 08:18:47 +0000 | [diff] [blame] | 255 | ax = os.path.join(a, x) |
| 256 | bx = os.path.join(b, x) |
Andrew M. Kuchling | 8eb4044 | 2003-02-06 17:50:01 +0000 | [diff] [blame] | 257 | res[_cmp(ax, bx, shallow)].append(x) |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 258 | return res |
| 259 | |
| 260 | |
| 261 | # Compare two files. |
| 262 | # Return: |
Tim Peters | 88869f9 | 2001-01-14 23:36:06 +0000 | [diff] [blame] | 263 | # 0 for equal |
| 264 | # 1 for different |
| 265 | # 2 for funny cases (can't stat, etc.) |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 266 | # |
Raymond Hettinger | 05595e9 | 2003-02-27 00:05:31 +0000 | [diff] [blame] | 267 | def _cmp(a, b, sh, abs=abs, cmp=cmp): |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 268 | try: |
Andrew M. Kuchling | 8eb4044 | 2003-02-06 17:50:01 +0000 | [diff] [blame] | 269 | return not abs(cmp(a, b, sh)) |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 270 | except os.error: |
| 271 | return 2 |
| 272 | |
| 273 | |
| 274 | # Return a copy with items that occur in skip removed. |
| 275 | # |
Raymond Hettinger | 05595e9 | 2003-02-27 00:05:31 +0000 | [diff] [blame] | 276 | def _filter(flist, skip): |
Raymond Hettinger | b0002d2 | 2008-03-13 01:41:43 +0000 | [diff] [blame] | 277 | return list(filterfalse(skip.__contains__, flist)) |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 278 | |
| 279 | |
| 280 | # Demonstration and testing. |
| 281 | # |
| 282 | def demo(): |
| 283 | import sys |
| 284 | import getopt |
| 285 | options, args = getopt.getopt(sys.argv[1:], 'r') |
Fred Drake | 8152d32 | 2000-12-12 23:20:45 +0000 | [diff] [blame] | 286 | if len(args) != 2: |
Andrew M. Kuchling | 83e879d | 2003-02-06 19:38:45 +0000 | [diff] [blame] | 287 | raise getopt.GetoptError('need exactly two args', None) |
Guido van Rossum | 63b08ac | 2000-06-29 14:13:28 +0000 | [diff] [blame] | 288 | dd = dircmp(args[0], args[1]) |
| 289 | if ('-r', '') in options: |
| 290 | dd.report_full_closure() |
| 291 | else: |
| 292 | dd.report() |
| 293 | |
| 294 | if __name__ == '__main__': |
| 295 | demo() |