MCPcopy
hub / github.com/cool-RR/PySnooper / touch

Method touch

tests/mini_toolbox/pathlib.py:1427–1448  ·  view source on GitHub ↗

Create this file with the given access mode, if it doesn't exist.

(self, mode=0o666, exist_ok=True)

Source from the content-addressed store, hash-verified

1425 return f.write(data)
1426
1427 def touch(self, mode=0o666, exist_ok=True):
1428 """
1429 Create this file with the given access mode, if it doesn't exist.
1430 """
1431 if self._closed:
1432 self._raise_closed()
1433 if exist_ok:
1434 # First try to bump modification time
1435 # Implementation note: GNU touch uses the UTIME_NOW option of
1436 # the utimensat() / futimens() functions.
1437 try:
1438 self._accessor.utime(self, None)
1439 except OSError:
1440 # Avoid exception chaining
1441 pass
1442 else:
1443 return
1444 flags = os.O_CREAT | os.O_WRONLY
1445 if not exist_ok:
1446 flags |= os.O_EXCL
1447 fd = self._raw_open(flags, mode)
1448 os.close(fd)
1449
1450 def mkdir(self, mode=0o777, parents=False, exist_ok=False):
1451 """

Callers

nothing calls this directly

Calls 3

_raise_closedMethod · 0.95
_raw_openMethod · 0.95
closeMethod · 0.80

Tested by

no test coverage detected