Initialize a single-file mailbox.
(self, path, factory=None, create=True)
| 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.""" |
nothing calls this directly
no test coverage detected