MCPcopy Index your code
hub / github.com/RustPython/RustPython / _create_tmp

Method _create_tmp

Lib/mailbox.py:540–562  ·  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

538 _count = 1 # This is used to generate unique file names.
539
540 def _create_tmp(self):
541 """Create a file in the tmp subdirectory and open and return it."""
542 now = time.time()
543 hostname = socket.gethostname()
544 if '/' in hostname:
545 hostname = hostname.replace('/', r'\057')
546 if ':' in hostname:
547 hostname = hostname.replace(':', r'\072')
548 uniq = "%s.M%sP%sQ%s.%s" % (int(now), int(now % 1 * 1e6), os.getpid(),
549 Maildir._count, hostname)
550 path = os.path.join(self._path, 'tmp', uniq)
551 try:
552 os.stat(path)
553 except FileNotFoundError:
554 Maildir._count += 1
555 try:
556 return _create_carefully(path)
557 except FileExistsError:
558 pass
559
560 # Fall through to here if stat succeeded or open raised EEXIST.
561 raise ExternalClashError('Name clash prevented file creation: %s' %
562 path)
563
564 def _refresh(self):
565 """Update table of contents mapping."""

Callers 2

addMethod · 0.95
test_create_tmpMethod · 0.80

Calls 6

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

Tested by 1

test_create_tmpMethod · 0.64