| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e63846d commit 8eb4044
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,6 @@ | |||
| 11 | 11 | ||
| 12 | 12 | import os | |
| 13 | 13 | import stat | |
| 14 | - import statcache | ||
| 15 | 14 | ||
| 16 | 15 | __all__ = ["cmp","dircmp","cmpfiles"] | |
| 17 | 16 | ||
@@ -30,25 +29,18 @@ def cmp(f1, f2, shallow=1, use_statcache=0): | |||
| 30 | 29 | shallow -- Just check stat signature (do not read the files). | |
| 31 | 30 | defaults to 1. | |
| 32 | 31 | ||
| 33 | - use_statcache -- Do not stat() each file directly: go through | ||
| 34 | - the statcache module for more efficiency. | ||
| 32 | + use_statcache -- obsolete argument. | ||
| 35 | 33 | ||
| 36 | 34 | Return value: | |
| 37 | 35 | ||
| 38 | 36 | True if the files are the same, False otherwise. | |
| 39 | 37 | ||
| 40 | 38 | This function uses a cache for past comparisons and the results, | |
| 41 | 39 | with a cache invalidation mechanism relying on stale signatures. | |
| 42 | - Of course, if 'use_statcache' is true, this mechanism is defeated, | ||
| 43 | - and the cache will never grow stale. | ||
| 44 | 40 | ||
| 45 | 41 | """ | |
| 46 | - if use_statcache: | ||
| 47 | - stat_function = statcache.stat | ||
| 48 | - else: | ||
| 49 | - stat_function = os.stat | ||
| 50 | - s1 = _sig(stat_function(f1)) | ||
| 51 | - s2 = _sig(stat_function(f2)) | ||
| 42 | + s1 = _sig(os.stat(f1)) | ||
| 43 | + s2 = _sig(os.stat(f2)) | ||
| 52 | 44 | if s1[0] != stat.S_IFREG or s2[0] != stat.S_IFREG: | |
| 53 | 45 | return False | |
| 54 | 46 | if shallow and s1 == s2: | |
@@ -188,12 +180,12 @@ def phase2(self): # Distinguish files, directories, funnies | |||
| 188 | 180 | ||
| 189 | 181 | ok = 1 | |
| 190 | 182 | try: | |
| 191 | - a_stat = statcache.stat(a_path) | ||
| 183 | + a_stat = os.stat(a_path) | ||
| 192 | 184 | except os.error, why: | |
| 193 | 185 | # print 'Can\'t stat', a_path, ':', why[1] | |
| 194 | 186 | ok = 0 | |
| 195 | 187 | try: | |
| 196 | - b_stat = statcache.stat(b_path) | ||
| 188 | + b_stat = os.stat(b_path) | ||
| 197 | 189 | except os.error, why: | |
| 198 | 190 | # print 'Can\'t stat', b_path, ':', why[1] | |
| 199 | 191 | ok = 0 | |
@@ -275,7 +267,7 @@ def cmpfiles(a, b, common, shallow=1, use_statcache=0): | |||
| 275 | 267 | a, b -- directory names | |
| 276 | 268 | common -- list of file names found in both directories | |
| 277 | 269 | shallow -- if true, do comparison based solely on stat() information | |
| 278 | - use_statcache -- if true, use statcache.stat() instead of os.stat() | ||
| 270 | + use_statcache -- obsolete argument | ||
| 279 | 271 | ||
| 280 | 272 | Returns a tuple of three lists: | |
| 281 | 273 | files that compare equal | |
@@ -287,7 +279,7 @@ def cmpfiles(a, b, common, shallow=1, use_statcache=0): | |||
| 287 | 279 | for x in common: | |
| 288 | 280 | ax = os.path.join(a, x) | |
| 289 | 281 | bx = os.path.join(b, x) | |
| 290 | - res[_cmp(ax, bx, shallow, use_statcache)].append(x) | ||
| 282 | + res[_cmp(ax, bx, shallow)].append(x) | ||
| 291 | 283 | return res | |
| 292 | 284 | ||
| 293 | 285 | ||
@@ -297,9 +289,9 @@ def cmpfiles(a, b, common, shallow=1, use_statcache=0): | |||
| 297 | 289 | # 1 for different | |
| 298 | 290 | # 2 for funny cases (can't stat, etc.) | |
| 299 | 291 | # | |
| 300 | - def _cmp(a, b, sh, st): | ||
| 292 | + def _cmp(a, b, sh): | ||
| 301 | 293 | try: | |
| 302 | - return not abs(cmp(a, b, sh, st)) | ||
| 294 | + return not abs(cmp(a, b, sh)) | ||
| 303 | 295 | except os.error: | |
| 304 | 296 | return 2 | |
| 305 | 297 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments