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

Method __init__

Lib/mailbox.py:632–653  ·  view source on GitHub ↗

Initialize a single-file mailbox.

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

Source from the content-addressed store, hash-verified

630 """A single-file mailbox."""
631
632 def __init__(self, path, factory=None, create=True):
633 """Initialize a single-file mailbox."""
634 Mailbox.__init__(self, path, factory, create)
635 try:
636 f = open(self._path, 'rb+')
637 except OSError as e:
638 if e.errno == errno.ENOENT:
639 if create:
640 f = open(self._path, 'wb+')
641 else:
642 raise NoSuchMailboxError(self._path)
643 elif e.errno in (errno.EACCES, errno.EROFS):
644 f = open(self._path, 'rb')
645 else:
646 raise
647 self._file = f
648 self._toc = None
649 self._next_key = 0
650 self._pending = False # No changes require rewriting the file.
651 self._pending_sync = False # No need to sync the file
652 self._locked = False
653 self._file_length = None # Used to record mailbox size
654
655 def add(self, message):
656 """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