MCPcopy Index your code
hub / github.com/microsoft/SandDance / compare_recursive_mtime

Function compare_recursive_mtime

python/jupyter-widget/setupbase.py:276–299  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

274
275
276def 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
302def recursive_mtime(path, newest=True):

Callers 1

is_staleFunction · 0.85

Calls 1

mtimeFunction · 0.85

Tested by

no test coverage detected