Compare the newest/oldest mtime for all files in a directory. Cutoff should be another mtime to be compared against. If an mtime that is newer/older than the cutoff is found it will return True. E.g. if newest=True, and a file in path is newer than the cutoff, it will return True.
(path, cutoff, newest=True)
| 274 | |
| 275 | |
| 276 | def compare_recursive_mtime(path, cutoff, newest=True): |
| 277 | """Compare the newest/oldest mtime for all files in a directory. |
| 278 | |
| 279 | Cutoff should be another mtime to be compared against. If an mtime that is |
| 280 | newer/older than the cutoff is found it will return True. |
| 281 | E.g. if newest=True, and a file in path is newer than the cutoff, it will |
| 282 | return True. |
| 283 | """ |
| 284 | if os.path.isfile(path): |
| 285 | mt = mtime(path) |
| 286 | if newest: |
| 287 | if mt > cutoff: |
| 288 | return True |
| 289 | elif mt < cutoff: |
| 290 | return True |
| 291 | for dirname, _, filenames in os.walk(path, topdown=False): |
| 292 | for filename in filenames: |
| 293 | mt = mtime(pjoin(dirname, filename)) |
| 294 | if newest: # Put outside of loop? |
| 295 | if mt > cutoff: |
| 296 | return True |
| 297 | elif mt < cutoff: |
| 298 | return True |
| 299 | return False |
| 300 | |
| 301 | |
| 302 | def recursive_mtime(path, newest=True): |