aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2018-04-22 23:39:05 +0200
committerMatěj Cepl <mcepl@cepl.eu>2018-04-22 23:39:05 +0200
commitf9a585d1c9901d0a38ec96732632052cc748f46a (patch)
treed3109aa98b9b6c1ee3a5841855a2c427d174207d
parent5798e5f8c0329bd2e603a4c8a3404a7a6dd7afd1 (diff)
downloadimapArch-f9a585d1c9901d0a38ec96732632052cc748f46a.tar.gz
Activate dir.move_messages
-rwxr-xr-xarchive_folder.py12
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()