Initialize a Maildir instance.
(self, dirname, factory=None, create=True)
| 277 | colon = ':' |
| 278 | |
| 279 | def __init__(self, dirname, factory=None, create=True): |
| 280 | """Initialize a Maildir instance.""" |
| 281 | Mailbox.__init__(self, dirname, factory, create) |
| 282 | self._paths = { |
| 283 | 'tmp': os.path.join(self._path, 'tmp'), |
| 284 | 'new': os.path.join(self._path, 'new'), |
| 285 | 'cur': os.path.join(self._path, 'cur'), |
| 286 | } |
| 287 | if not os.path.exists(self._path): |
| 288 | if create: |
| 289 | os.mkdir(self._path, 0o700) |
| 290 | for path in self._paths.values(): |
| 291 | os.mkdir(path, 0o700) |
| 292 | else: |
| 293 | raise NoSuchMailboxError(self._path) |
| 294 | self._toc = {} |
| 295 | self._toc_mtimes = {'cur': 0, 'new': 0} |
| 296 | self._last_read = 0 # Records last time we read cur/new |
| 297 | self._skewfactor = 0.1 # Adjust if os/fs clocks are skewing |
| 298 | |
| 299 | def add(self, message): |
| 300 | """Add message and return assigned key.""" |