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