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 d
(a, b, common, shallow=True)
| 256 | |
| 257 | |
| 258 | def cmpfiles(a, b, common, shallow=True): |
| 259 | """Compare common files in two directories. |
| 260 | |
| 261 | a, b -- directory names |
| 262 | common -- list of file names found in both directories |
| 263 | shallow -- if true, do comparison based solely on stat() information |
| 264 | |
| 265 | Returns a tuple of three lists: |
| 266 | files that compare equal |
| 267 | files that are different |
| 268 | filenames that aren't regular files. |
| 269 | |
| 270 | """ |
| 271 | res = ([], [], []) |
| 272 | for x in common: |
| 273 | ax = os.path.join(a, x) |
| 274 | bx = os.path.join(b, x) |
| 275 | res[_cmp(ax, bx, shallow)].append(x) |
| 276 | return res |
| 277 | |
| 278 | |
| 279 | # Compare two files. |