Compare common files in two directories. a, b -- directory names common -- list of file names found in both directories shallow -- if true, do comparison based solely on stat() information Returns a tuple of three lists: files that compare equal files that are different
(a, b, common, shallow=True)
| 263 | |
| 264 | |
| 265 | def cmpfiles(a, b, common, shallow=True): |
| 266 | """Compare common files in two directories. |
| 267 | |
| 268 | a, b -- directory names |
| 269 | common -- list of file names found in both directories |
| 270 | shallow -- if true, do comparison based solely on stat() information |
| 271 | |
| 272 | Returns a tuple of three lists: |
| 273 | files that compare equal |
| 274 | files that are different |
| 275 | filenames that aren't regular files. |
| 276 | |
| 277 | """ |
| 278 | res = ([], [], []) |
| 279 | for x in common: |
| 280 | ax = os.path.join(a, x) |
| 281 | bx = os.path.join(b, x) |
| 282 | res[_cmp(ax, bx, shallow)].append(x) |
| 283 | return res |
| 284 | |
| 285 | |
| 286 | # Compare two files. |