added command line options for mindate
This commit is contained in:
parent
0599193ba5
commit
33ce737b57
31
archivemail
31
archivemail
|
|
@ -180,6 +180,8 @@ class Options:
|
||||||
archive_name = None
|
archive_name = None
|
||||||
days_old_max = 180
|
days_old_max = 180
|
||||||
date_old_max = None
|
date_old_max = None
|
||||||
|
days_old_min = 360
|
||||||
|
date_old_min = None
|
||||||
delete_old_mail = False
|
delete_old_mail = False
|
||||||
dry_run = False
|
dry_run = False
|
||||||
filter_append = None
|
filter_append = None
|
||||||
|
|
@ -215,8 +217,8 @@ class Options:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(args, '?D:S:Vd:hno:F:P:qs:p:a:uv',
|
opts, args = getopt.getopt(args, '?D:M:S:Vd:m:hno:F:P:qs:p:a:uv',
|
||||||
["date=", "days=", "delete", "dry-run", "help",
|
["date=", "days=", "mindate=", "mindays=", "delete", "dry-run", "help",
|
||||||
"include-flagged", "no-compress", "output-dir=",
|
"include-flagged", "no-compress", "output-dir=",
|
||||||
"filter-append=", "pwfile=", "dont-mangle",
|
"filter-append=", "pwfile=", "dont-mangle",
|
||||||
"preserve-unread", "quiet", "size=", "suffix=",
|
"preserve-unread", "quiet", "size=", "suffix=",
|
||||||
|
|
@ -226,7 +228,8 @@ class Options:
|
||||||
except getopt.error, msg:
|
except getopt.error, msg:
|
||||||
user_error(msg)
|
user_error(msg)
|
||||||
|
|
||||||
archive_by = None
|
archive_by_max = None
|
||||||
|
archive_by_min = None
|
||||||
|
|
||||||
for o, a in opts:
|
for o, a in opts:
|
||||||
if o == '--delete':
|
if o == '--delete':
|
||||||
|
|
@ -240,15 +243,25 @@ class Options:
|
||||||
if o == '--warn-duplicate':
|
if o == '--warn-duplicate':
|
||||||
self.warn_duplicates = True
|
self.warn_duplicates = True
|
||||||
if o in ('-D', '--date'):
|
if o in ('-D', '--date'):
|
||||||
if archive_by:
|
if archive_by_max:
|
||||||
user_error("you cannot specify both -d and -D options")
|
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)
|
self.date_old_max = self.date_argument(a)
|
||||||
if o in ('-d', '--days'):
|
if o in ('-d', '--days'):
|
||||||
if archive_by:
|
if archive_by_max:
|
||||||
user_error("you cannot specify both -d and -D options")
|
user_error("you cannot specify both -d and -D options")
|
||||||
archive_by = "days"
|
archive_by_max = "days"
|
||||||
self.days_old_max = string.atoi(a)
|
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'):
|
if o in ('-o', '--output-dir'):
|
||||||
self.output_dir = os.path.expanduser(a)
|
self.output_dir = os.path.expanduser(a)
|
||||||
if o in ('-P', '--pwfile'):
|
if o in ('-P', '--pwfile'):
|
||||||
|
|
@ -653,6 +666,8 @@ mailbox compressed with gzip.
|
||||||
Options are as follows:
|
Options are as follows:
|
||||||
-d, --days=NUM archive messages older than NUM days (default: %d)
|
-d, --days=NUM archive messages older than NUM days (default: %d)
|
||||||
-D, --date=DATE archive messages older than DATE
|
-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)
|
-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
|
-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)
|
(substitute 'imap' with 'imaps' for an SSL connection)
|
||||||
|
|
||||||
Website: http://archivemail.sourceforge.net/ """ % \
|
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)
|
options.script_name, options.days_old_max)
|
||||||
|
|
||||||
args = options.parse_args(args, usage)
|
args = options.parse_args(args, usage)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue