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

Method __init__

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

Initialize a single-file mailbox.

(self, path, factory=None, create=True)

Source from the content-addressed store, hash-verified

578 """A single-file mailbox."""
579
580 def __init__(self, path, factory=None, create=True):
581 """Initialize a single-file mailbox."""
582 Mailbox.__init__(self, path, factory, create)
583 try:
584 f = open(self._path, 'rb+')
585 except OSError as e:
586 if e.errno == errno.ENOENT:
587 if create:
588 f = open(self._path, 'wb+')
589 else:
590 raise NoSuchMailboxError(self._path)
591 elif e.errno in (errno.EACCES, errno.EROFS):
592 f = open(self._path, 'rb')
593 else:
594 raise
595 self._file = f
596 self._toc = None
597 self._next_key = 0
598 self._pending = False # No changes require rewriting the file.
599 self._pending_sync = False # No need to sync the file
600 self._locked = False
601 self._file_length = None # Used to record mailbox size
602
603 def add(self, message):
604 """Add message and return assigned key."""

Callers

nothing calls this directly

Calls 3

NoSuchMailboxErrorClass · 0.85
openFunction · 0.70
__init__Method · 0.45

Tested by

no test coverage detected