MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _create_tmp

Method _create_tmp

tools/python-3.11.9-amd64/Lib/mailbox.py:490–512  ·  view source on GitHub ↗

Create a file in the tmp subdirectory and open and return it.

(self)

Source from the content-addressed store, hash-verified

488 _count = 1 # This is used to generate unique file names.
489
490 def _create_tmp(self):
491 """Create a file in the tmp subdirectory and open and return it."""
492 now = time.time()
493 hostname = socket.gethostname()
494 if '/' in hostname:
495 hostname = hostname.replace('/', r'\057')
496 if ':' in hostname:
497 hostname = hostname.replace(':', r'\072')
498 uniq = "%s.M%sP%sQ%s.%s" % (int(now), int(now % 1 * 1e6), os.getpid(),
499 Maildir._count, hostname)
500 path = os.path.join(self._path, 'tmp', uniq)
501 try:
502 os.stat(path)
503 except FileNotFoundError:
504 Maildir._count += 1
505 try:
506 return _create_carefully(path)
507 except FileExistsError:
508 pass
509
510 # Fall through to here if stat succeeded or open raised EEXIST.
511 raise ExternalClashError('Name clash prevented file creation: %s' %
512 path)
513
514 def _refresh(self):
515 """Update table of contents mapping."""

Callers 1

addMethod · 0.95

Calls 6

_create_carefullyFunction · 0.85
ExternalClashErrorClass · 0.85
timeMethod · 0.45
replaceMethod · 0.45
joinMethod · 0.45
statMethod · 0.45

Tested by

no test coverage detected