MCPcopy
hub / github.com/pex-tool/pex / touch

Function touch

pex/common.py:640–653  ·  view source on GitHub ↗

Equivalent of unix `touch path`. If no times is passed, the current time is used to set atime and mtime. If a single int or float is passed for times, it is used for both atime and mtime. If a 2-tuple of ints or floats is passed, the 1st slot is the atime and the 2nd the mtime, just as

(
    file,  # type: _Text
    times=None,  # type: Optional[Union[int, float, Tuple[int, int], Tuple[float, float]]]
)

Source from the content-addressed store, hash-verified

638
639
640def touch(
641 file, # type: _Text
642 times=None, # type: Optional[Union[int, float, Tuple[int, int], Tuple[float, float]]]
643):
644 # type: (...) -> _Text
645 """Equivalent of unix `touch path`.
646
647 If no times is passed, the current time is used to set atime and mtime. If a single int or float
648 is passed for times, it is used for both atime and mtime. If a 2-tuple of ints or floats is
649 passed, the 1st slot is the atime and the 2nd the mtime, just as for `os.utime`.
650 """
651 with safe_open(file, "a"):
652 os.utime(file, (times, times) if isinstance(times, (int, float)) else times)
653 return file
654
655
656class Chroot(object):

Callers 15

install_wheelFunction · 0.90
record_accessFunction · 0.90
test_directory_hasherFunction · 0.90
test_zip_file_type_modeFunction · 0.90
zip_fixtureFunction · 0.90
assert_chroot_permsFunction · 0.90
test_deterministic_walkFunction · 0.90
test_parse_invalidFunction · 0.90

Calls 1

safe_openFunction · 0.85