Return a Message representation or raise a KeyError.
(self, key)
| 378 | os.rename(tmp_path, new_path) |
| 379 | |
| 380 | def get_message(self, key): |
| 381 | """Return a Message representation or raise a KeyError.""" |
| 382 | subpath = self._lookup(key) |
| 383 | with open(os.path.join(self._path, subpath), 'rb') as f: |
| 384 | if self._factory: |
| 385 | msg = self._factory(f) |
| 386 | else: |
| 387 | msg = MaildirMessage(f) |
| 388 | subdir, name = os.path.split(subpath) |
| 389 | msg.set_subdir(subdir) |
| 390 | if self.colon in name: |
| 391 | msg.set_info(name.split(self.colon)[-1]) |
| 392 | msg.set_date(os.path.getmtime(os.path.join(self._path, subpath))) |
| 393 | return msg |
| 394 | |
| 395 | def get_bytes(self, key): |
| 396 | """Return a bytes representation or raise a KeyError.""" |