Skip to content

Commit

Permalink
Move mails
Browse files Browse the repository at this point in the history
Actually move mail files identified for syncing (cf issue #4).
Dry mode not yet supported (cf issue #9).
  • Loading branch information
0x64746b authored and Justus Winter committed Apr 16, 2012
1 parent dd7c589 commit f35e87c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions afew/TagSyncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


import notmuch
from shutil import move

from .Database import Database

Expand All @@ -41,12 +42,15 @@ def sync(self, maildir, rules):
'''
messages = notmuch.Query(self.db, self.query.format(folder=maildir)).search_messages()
for message in messages:
print u"{} -- {}".format(message, message.get_header('Subject'))
mail_tags = list(message.get_tags())
for tag in rules.keys():
if self.__rule_matches(tag, mail_tags):
print " WOULD MOVE TO: {}/{}/cur/ ".format(self.db_path,
rules[tag])
destination = '{}/{}/cur/'.format(self.db_path, rules[tag])
print u"DEBUG: {} -- {} [{}]".format(message,
message.get_header('Subject'),
message.get_filename().rsplit('/', 1)[1])
print u"DEBUG: MOVING TO: {}".format(destination)
move(message.get_filename(), destination)
break


Expand Down
1 change: 1 addition & 0 deletions afew/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,6 @@ def main(options, query_string):
('sailing', 'interests.sailing'),
('!inbox', 'Archive')])
)
syncher.sync('Junk', OrderedDict([('!spam', 'Archive')]))
else:
sys.exit('Weird... please file a bug containing your command line.')

0 comments on commit f35e87c

Please sign in to comment.