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