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]]]
)
| 638 | |
| 639 | |
| 640 | def 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 | |
| 656 | class Chroot(object): |