MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / copytime

Function copytime

src/commoncode/fileutils.py:455–473  ·  view source on GitHub ↗

Copy timestamps from `src` to `dst`. Similar to and derived from Python shutil module. See fileutils.py.ABOUT for details.

(src, dst)

Source from the content-addressed store, hash-verified

453
454
455def copytime(src, dst):
456 """
457 Copy timestamps from `src` to `dst`.
458
459 Similar to and derived from Python shutil module. See fileutils.py.ABOUT
460 for details.
461 """
462 errors = []
463 st = os.stat(src)
464 if hasattr(os, "utime"):
465 try:
466 os.utime(dst, (st.st_atime, st.st_mtime))
467 except OSError as why:
468 if WindowsError is not None and isinstance(why, WindowsError):
469 # File access times cannot be copied on Windows
470 pass
471 else:
472 errors.append((src, dst, str(why)))
473 return errors
474
475
476#

Callers 2

copytreeFunction · 0.85
copyfileFunction · 0.85

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected