Gets the newest/oldest mtime for all files in a directory.
(path, newest=True)
| 300 | |
| 301 | |
| 302 | def recursive_mtime(path, newest=True): |
| 303 | """Gets the newest/oldest mtime for all files in a directory.""" |
| 304 | if os.path.isfile(path): |
| 305 | return mtime(path) |
| 306 | current_extreme = None |
| 307 | for dirname, dirnames, filenames in os.walk(path, topdown=False): |
| 308 | for filename in filenames: |
| 309 | mt = mtime(pjoin(dirname, filename)) |
| 310 | if newest: # Put outside of loop? |
| 311 | if mt >= (current_extreme or mt): |
| 312 | current_extreme = mt |
| 313 | elif mt <= (current_extreme or mt): |
| 314 | current_extreme = mt |
| 315 | return current_extreme |
| 316 | |
| 317 | |
| 318 | def mtime(path): |