'Initialize a single-file mailbox.'

def __init__(self, path, factory=None, create=True):

    Mailbox.__init__(self, path, factory, create)
    try:
        f = open(self._path, 'rb+')
    except IOError as e:
        if (e.errno == errno.ENOENT):
            if create:
                f = open(self._path, 'wb+')
            else:
                raise NoSuchMailboxError(self._path)
        elif (e.errno in (errno.EACCES, errno.EROFS)):
            f = open(self._path, 'rb')
        else:
            raise
    self._file = f
    self._toc = None
    self._next_key = 0
    self._pending = False
    self._pending_sync = False
    self._locked = False
    self._file_length = None
