1
0
Fork 0
mirror of https://git.code.sf.net/p/archivemail/code synced 2024-12-23 16:25:36 +00:00

new command line option: -F, --filter-append=STRING append arbitrary string to the IMAP filter string

This commit is contained in:
Peter Poeml 2006-06-27 04:40:24 +00:00
parent adfb7a63d7
commit e00581acb2

View file

@ -143,6 +143,7 @@ class Options:
date_old_max = None date_old_max = None
delete_old_mail = 0 delete_old_mail = 0
dry_run = 0 dry_run = 0
filter_append = None
include_flagged = 0 include_flagged = 0
lockfile_attempts = 5 lockfile_attempts = 5
lockfile_extension = ".lock" lockfile_extension = ".lock"
@ -171,10 +172,10 @@ class Options:
""" """
try: try:
opts, args = getopt.getopt(args, '?D:S:Vd:hno:P:qs:uv', opts, args = getopt.getopt(args, '?D:S:Vd:hno:F:P:qs:uv',
["date=", "days=", "delete", "dry-run", "help", ["date=", "days=", "delete", "dry-run", "help",
"include-flagged", "no-compress", "output-dir=", "include-flagged", "no-compress", "output-dir=",
"pwfile", "filter-append", "pwfile",
"preserve-unread", "quiet", "size=", "suffix=", "preserve-unread", "quiet", "size=", "suffix=",
"verbose", "version", "warn-duplicate"]) "verbose", "version", "warn-duplicate"])
except getopt.error, msg: except getopt.error, msg:
@ -205,6 +206,8 @@ class Options:
self.output_dir = a self.output_dir = a
if o in ('-P', '--pwfile'): if o in ('-P', '--pwfile'):
self.pwfile = a self.pwfile = a
if o in ('-F', '--filter-append'):
self.filter_append = a
if o in ('-h', '-?', '--help'): if o in ('-h', '-?', '--help'):
print usage print usage
sys.exit(0) sys.exit(0)
@ -591,6 +594,7 @@ Options are as follows:
-D, --date=DATE archive messages older than DATE -D, --date=DATE archive messages older than DATE
-o, --output-dir=DIR directory to store archives (default: same as original) -o, --output-dir=DIR directory to store archives (default: same as original)
-P, --pwfile=FILE file to read imap password from (default: None) -P, --pwfile=FILE file to read imap password from (default: None)
-F, --filter-append=STRING append arbitrary string to the IMAP filter string
-s, --suffix=NAME suffix for archive filename (default: '%s') -s, --suffix=NAME suffix for archive filename (default: '%s')
-S, --size=NUM only archive messages NUM bytes or larger -S, --size=NUM only archive messages NUM bytes or larger
-n, --dry-run don't write to anything - just show what would be done -n, --dry-run don't write to anything - just show what would be done
@ -977,6 +981,9 @@ def build_imap_filter():
if options.preserve_unread: if options.preserve_unread:
filter.append("SEEN") filter.append("SEEN")
if options.filter_append:
filter.append(options.filter_append)
return '(' + string.join(filter, ' ') + ')' return '(' + string.join(filter, ' ') + ')'
############### mailbox operations ############### ############### mailbox operations ###############