newerthan #1

Merged
mwtkrayer merged 6 commits from newerthan into master 2020-05-22 11:55:05 +00:00
1 changed files with 23 additions and 8 deletions
Showing only changes of commit 33ce737b57 - Show all commits

View File

@ -180,6 +180,8 @@ class Options:
archive_name = None
days_old_max = 180
date_old_max = None
days_old_min = 360
date_old_min = None
delete_old_mail = False
dry_run = False
filter_append = None
@ -215,8 +217,8 @@ class Options:
"""
try:
opts, args = getopt.getopt(args, '?D:S:Vd:hno:F:P:qs:p:a:uv',
["date=", "days=", "delete", "dry-run", "help",
opts, args = getopt.getopt(args, '?D:M:S:Vd:m:hno:F:P:qs:p:a:uv',
["date=", "days=", "mindate=", "mindays=", "delete", "dry-run", "help",
"include-flagged", "no-compress", "output-dir=",
"filter-append=", "pwfile=", "dont-mangle",
"preserve-unread", "quiet", "size=", "suffix=",
@ -226,7 +228,8 @@ class Options:
except getopt.error, msg:
user_error(msg)
archive_by = None
archive_by_max = None
archive_by_min = None
for o, a in opts:
if o == '--delete':
@ -240,15 +243,25 @@ class Options:
if o == '--warn-duplicate':
self.warn_duplicates = True
if o in ('-D', '--date'):
if archive_by:
if archive_by_max:
user_error("you cannot specify both -d and -D options")
archive_by = "date"
archive_by_max = "date"
self.date_old_max = self.date_argument(a)
if o in ('-d', '--days'):
if archive_by:
if archive_by_max:
user_error("you cannot specify both -d and -D options")
archive_by = "days"
archive_by_max = "days"
self.days_old_max = string.atoi(a)
if o in ('-M', '--mindate'):
if archive_by_min:
user_error("you cannot specify both -m and -M options")
archive_by_min = "date"
self.date_old_min = self.date_argument(a)
if o in ('-m', '--mindays'):
if archive_by_min:
user_error("you cannot specify both -m and -M options")
archive_by_min = "days"
self.days_old_min = string.atoi(a)
if o in ('-o', '--output-dir'):
self.output_dir = os.path.expanduser(a)
if o in ('-P', '--pwfile'):
@ -653,6 +666,8 @@ mailbox compressed with gzip.
Options are as follows:
-d, --days=NUM archive messages older than NUM days (default: %d)
-D, --date=DATE archive messages older than DATE
-m, --mindays=NUM archive messages newer than NUM days (default: %d)
-N, --mindate=DATE archive messages newer than DATE
-o, --output-dir=DIR directory to store archives (default: same as original)
-P, --pwfile=FILE file to read imap password from (default: None)
-F, --filter-append=STRING append arbitrary string to the IMAP filter string
@ -686,7 +701,7 @@ To archive IMAP mailboxes, format your mailbox argument like this:
(substitute 'imap' with 'imaps' for an SSL connection)
Website: http://archivemail.sourceforge.net/ """ % \
(options.script_name, options.days_old_max, options.archive_suffix,
(options.script_name, options.days_old_max, options.days_old_min, options.archive_suffix,
options.script_name, options.days_old_max)
args = options.parse_args(args, usage)