diff options
-rwxr-xr-x | archive_folder.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/archive_folder.py b/archive_folder.py index 3d52918..8bc9017 100755 --- a/archive_folder.py +++ b/archive_folder.py @@ -36,15 +36,16 @@ FOLDER_RE = re.compile(r'\s+"[/.]"\s+') class Message(object): """Abstraction over one email message.""" - def __init__(self, client, uid): - self.client = client + def __init__(self, folder, uid): + self.folder = folder + self.box = self.folder.box self.uid = uid self.msg = self.__get_body() self.date = email.utils.parsedate_to_datetime(self.msg['Date']) self.subject = self.__get_subject() def __get_body(self): - typ, data = self.client.uid('FETCH', '%s (RFC822)' % self.uid) + typ, data = self.box.uid('FETCH', '%s (RFC822)' % self.uid) if typ == 'OK': return email.message_from_bytes(data[0][1]) else: @@ -61,7 +62,8 @@ class Message(object): return out_str def __str__(self): - return "%s: %s (%s)" % (self.uid, self.subject, self.date) + return "%s in %s: %s (%s)" % (self.uid, self.folder.fld_name, + self.subject, self.date) class Folder(object): @@ -230,7 +232,7 @@ class EmailServer(object): log.debug('arch_dir = %s, msgs = %s', arch_dir, msg_ids) dir = Folder(self.box, arch_dir, create=True) - # dir.move_messages(msg_ids) + dir.move_messages(msg_ids) def list_folders(self): ok, data = self.box.list() |