mirror of
https://git.code.sf.net/p/archivemail/code
synced 2025-01-03 05:34:58 +00:00
Python language fix: replace C-style boolean values "1" and "0" with True/False
This commit is contained in:
parent
7269c32734
commit
e5ee9b98c1
2 changed files with 100 additions and 100 deletions
|
@ -174,28 +174,28 @@ class Options:
|
||||||
archive_suffix = "_archive"
|
archive_suffix = "_archive"
|
||||||
days_old_max = 180
|
days_old_max = 180
|
||||||
date_old_max = None
|
date_old_max = None
|
||||||
delete_old_mail = 0
|
delete_old_mail = False
|
||||||
dry_run = 0
|
dry_run = False
|
||||||
filter_append = None
|
filter_append = None
|
||||||
include_flagged = 0
|
include_flagged = False
|
||||||
locking_attempts = 5
|
locking_attempts = 5
|
||||||
lockfile_extension = ".lock"
|
lockfile_extension = ".lock"
|
||||||
lock_sleep = 1
|
lock_sleep = True
|
||||||
no_compress = 0
|
no_compress = False
|
||||||
only_archive_read = 0
|
only_archive_read = False
|
||||||
output_dir = None
|
output_dir = None
|
||||||
pwfile = None
|
pwfile = None
|
||||||
preserve_unread = 0
|
preserve_unread = False
|
||||||
mangle_from = 1
|
mangle_from = True
|
||||||
quiet = 0
|
quiet = False
|
||||||
read_buffer_size = 8192
|
read_buffer_size = 8192
|
||||||
script_name = os.path.basename(sys.argv[0])
|
script_name = os.path.basename(sys.argv[0])
|
||||||
min_size = None
|
min_size = None
|
||||||
verbose = 0
|
verbose = False
|
||||||
debug_imap = 0
|
debug_imap = False
|
||||||
warn_duplicates = 0
|
warn_duplicates = False
|
||||||
copy_old_mail = 0
|
copy_old_mail = False
|
||||||
archive_all = 0
|
archive_all = False
|
||||||
|
|
||||||
def parse_args(self, args, usage):
|
def parse_args(self, args, usage):
|
||||||
"""Set our runtime options from the command-line arguments.
|
"""Set our runtime options from the command-line arguments.
|
||||||
|
@ -225,13 +225,13 @@ class Options:
|
||||||
if o == '--delete':
|
if o == '--delete':
|
||||||
if self.copy_old_mail:
|
if self.copy_old_mail:
|
||||||
user_error("found conflicting options --copy and --delete")
|
user_error("found conflicting options --copy and --delete")
|
||||||
self.delete_old_mail = 1
|
self.delete_old_mail = True
|
||||||
if o == '--include-flagged':
|
if o == '--include-flagged':
|
||||||
self.include_flagged = 1
|
self.include_flagged = True
|
||||||
if o == '--no-compress':
|
if o == '--no-compress':
|
||||||
self.no_compress = 1
|
self.no_compress = True
|
||||||
if o == '--warn-duplicate':
|
if o == '--warn-duplicate':
|
||||||
self.warn_duplicates = 1
|
self.warn_duplicates = True
|
||||||
if o in ('-D', '--date'):
|
if o in ('-D', '--date'):
|
||||||
if archive_by:
|
if archive_by:
|
||||||
user_error("you cannot specify both -d and -D options")
|
user_error("you cannot specify both -d and -D options")
|
||||||
|
@ -252,27 +252,27 @@ class Options:
|
||||||
print usage
|
print usage
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
if o in ('-n', '--dry-run'):
|
if o in ('-n', '--dry-run'):
|
||||||
self.dry_run = 1
|
self.dry_run = True
|
||||||
if o in ('-q', '--quiet'):
|
if o in ('-q', '--quiet'):
|
||||||
self.quiet = 1
|
self.quiet = True
|
||||||
if o in ('-s', '--suffix'):
|
if o in ('-s', '--suffix'):
|
||||||
self.archive_suffix = a
|
self.archive_suffix = a
|
||||||
if o in ('-S', '--size'):
|
if o in ('-S', '--size'):
|
||||||
self.min_size = string.atoi(a)
|
self.min_size = string.atoi(a)
|
||||||
if o in ('-u', '--preserve-unread'):
|
if o in ('-u', '--preserve-unread'):
|
||||||
self.preserve_unread = 1
|
self.preserve_unread = True
|
||||||
if o == '--dont-mangle':
|
if o == '--dont-mangle':
|
||||||
self.mangle_from = 0
|
self.mangle_from = False
|
||||||
if o in ('-v', '--verbose'):
|
if o in ('-v', '--verbose'):
|
||||||
self.verbose = 1
|
self.verbose = True
|
||||||
if o == '--debug-imap':
|
if o == '--debug-imap':
|
||||||
self.debug_imap = int(a)
|
self.debug_imap = int(a)
|
||||||
if o == '--copy':
|
if o == '--copy':
|
||||||
if self.delete_old_mail:
|
if self.delete_old_mail:
|
||||||
user_error("found conflicting options --copy and --delete")
|
user_error("found conflicting options --copy and --delete")
|
||||||
self.copy_old_mail = 1
|
self.copy_old_mail = True
|
||||||
if o == '--all':
|
if o == '--all':
|
||||||
self.archive_all = 1
|
self.archive_all = True
|
||||||
if o in ('-V', '--version'):
|
if o in ('-V', '--version'):
|
||||||
print __version__ + "\n\n" + __copyright__
|
print __version__ + "\n\n" + __copyright__
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
@ -301,7 +301,7 @@ class Options:
|
||||||
"%d %b %Y" , # Internet format
|
"%d %b %Y" , # Internet format
|
||||||
"%d %B %Y" , # Internet format with full month names
|
"%d %B %Y" , # Internet format with full month names
|
||||||
)
|
)
|
||||||
time.accept2dyear = 0 # I'm not going to support 2-digit years
|
time.accept2dyear = False # I'm not going to support 2-digit years
|
||||||
for format in date_formats:
|
for format in date_formats:
|
||||||
try:
|
try:
|
||||||
date = time.strptime(string, format)
|
date = time.strptime(string, format)
|
||||||
|
@ -536,7 +536,7 @@ class TempMbox:
|
||||||
# practice to 'self.mbox_file.writelines(msg.fp.readlines())'
|
# practice to 'self.mbox_file.writelines(msg.fp.readlines())'
|
||||||
assert options.read_buffer_size > 0
|
assert options.read_buffer_size > 0
|
||||||
linebuf = ""
|
linebuf = ""
|
||||||
while 1:
|
while True:
|
||||||
body = msg.fp.read(options.read_buffer_size)
|
body = msg.fp.read(options.read_buffer_size)
|
||||||
if (not msg_has_mbox_format) and options.mangle_from:
|
if (not msg_has_mbox_format) and options.mangle_from:
|
||||||
# Be careful not to break pattern matching
|
# Be careful not to break pattern matching
|
||||||
|
@ -617,7 +617,7 @@ class IdentityCache:
|
||||||
if self.seen_ids.has_key(message_id):
|
if self.seen_ids.has_key(message_id):
|
||||||
user_warning("duplicate message id: '%s' in mailbox '%s'" %
|
user_warning("duplicate message id: '%s' in mailbox '%s'" %
|
||||||
(message_id, self.mailbox_name))
|
(message_id, self.mailbox_name))
|
||||||
self.seen_ids[message_id] = 1
|
self.seen_ids[message_id] = True
|
||||||
|
|
||||||
|
|
||||||
# global class instances
|
# global class instances
|
||||||
|
@ -892,7 +892,7 @@ def is_flagged(message):
|
||||||
x_status = message.get('X-Status')
|
x_status = message.get('X-Status')
|
||||||
if x_status and re.search('F', x_status):
|
if x_status and re.search('F', x_status):
|
||||||
vprint("message is important (X-Status header='%s')" % x_status)
|
vprint("message is important (X-Status header='%s')" % x_status)
|
||||||
return 1
|
return True
|
||||||
file_name = None
|
file_name = None
|
||||||
try:
|
try:
|
||||||
file_name = get_filename(message)
|
file_name = get_filename(message)
|
||||||
|
@ -901,9 +901,9 @@ def is_flagged(message):
|
||||||
# maildir mailboxes use the filename suffix to indicate flagged status
|
# maildir mailboxes use the filename suffix to indicate flagged status
|
||||||
if file_name and re.search(":2,.*F.*$", file_name):
|
if file_name and re.search(":2,.*F.*$", file_name):
|
||||||
vprint("message is important (filename info has 'F')")
|
vprint("message is important (filename info has 'F')")
|
||||||
return 1
|
return True
|
||||||
vprint("message is not flagged important")
|
vprint("message is not flagged important")
|
||||||
return 0
|
return False
|
||||||
|
|
||||||
|
|
||||||
def is_unread(message):
|
def is_unread(message):
|
||||||
|
@ -912,7 +912,7 @@ def is_unread(message):
|
||||||
status = message.get('Status')
|
status = message.get('Status')
|
||||||
if status and re.search('R', status):
|
if status and re.search('R', status):
|
||||||
vprint("message has been read (status header='%s')" % status)
|
vprint("message has been read (status header='%s')" % status)
|
||||||
return 0
|
return False
|
||||||
file_name = None
|
file_name = None
|
||||||
try:
|
try:
|
||||||
file_name = get_filename(message)
|
file_name = get_filename(message)
|
||||||
|
@ -921,9 +921,9 @@ def is_unread(message):
|
||||||
# maildir mailboxes use the filename suffix to indicate read status
|
# maildir mailboxes use the filename suffix to indicate read status
|
||||||
if file_name and re.search(":2,.*S.*$", file_name):
|
if file_name and re.search(":2,.*S.*$", file_name):
|
||||||
vprint("message has been read (filename info has 'S')")
|
vprint("message has been read (filename info has 'S')")
|
||||||
return 0
|
return False
|
||||||
vprint("message is unread")
|
vprint("message is unread")
|
||||||
return 1
|
return True
|
||||||
|
|
||||||
|
|
||||||
def sizeof_message(message):
|
def sizeof_message(message):
|
||||||
|
@ -961,18 +961,18 @@ def is_smaller(message, size):
|
||||||
if message_size < size:
|
if message_size < size:
|
||||||
vprint("message is too small (%d bytes), minimum bytes : %d" % \
|
vprint("message is too small (%d bytes), minimum bytes : %d" % \
|
||||||
(message_size, size))
|
(message_size, size))
|
||||||
return 1
|
return True
|
||||||
else:
|
else:
|
||||||
vprint("message is not too small (%d bytes), minimum bytes: %d" % \
|
vprint("message is not too small (%d bytes), minimum bytes: %d" % \
|
||||||
(message_size, size))
|
(message_size, size))
|
||||||
return 0
|
return False
|
||||||
|
|
||||||
|
|
||||||
def should_archive(message):
|
def should_archive(message):
|
||||||
"""Return true if we should archive the message, false otherwise"""
|
"""Return true if we should archive the message, false otherwise"""
|
||||||
if options.archive_all:
|
if options.archive_all:
|
||||||
return 1
|
return True
|
||||||
old = 0
|
old = False
|
||||||
time_message = guess_delivery_time(message)
|
time_message = guess_delivery_time(message)
|
||||||
if options.date_old_max == None:
|
if options.date_old_max == None:
|
||||||
old = is_older_than_days(time_message, options.days_old_max)
|
old = is_older_than_days(time_message, options.days_old_max)
|
||||||
|
@ -982,14 +982,14 @@ def should_archive(message):
|
||||||
# I could probably do this in one if statement, but then I wouldn't
|
# I could probably do this in one if statement, but then I wouldn't
|
||||||
# understand it.
|
# understand it.
|
||||||
if not old:
|
if not old:
|
||||||
return 0
|
return False
|
||||||
if not options.include_flagged and is_flagged(message):
|
if not options.include_flagged and is_flagged(message):
|
||||||
return 0
|
return False
|
||||||
if options.min_size and is_smaller(message, options.min_size):
|
if options.min_size and is_smaller(message, options.min_size):
|
||||||
return 0
|
return False
|
||||||
if options.preserve_unread and is_unread(message):
|
if options.preserve_unread and is_unread(message):
|
||||||
return 0
|
return False
|
||||||
return 1
|
return True
|
||||||
|
|
||||||
|
|
||||||
def is_older_than_time(time_message, max_time):
|
def is_older_than_time(time_message, max_time):
|
||||||
|
@ -1005,10 +1005,10 @@ def is_older_than_time(time_message, max_time):
|
||||||
days_old = (max_time - time_message) / 24 / 60 / 60
|
days_old = (max_time - time_message) / 24 / 60 / 60
|
||||||
if time_message < max_time:
|
if time_message < max_time:
|
||||||
vprint("message is %.2f days older than the specified date" % days_old)
|
vprint("message is %.2f days older than the specified date" % days_old)
|
||||||
return 1
|
return True
|
||||||
vprint("message is %.2f days younger than the specified date" % \
|
vprint("message is %.2f days younger than the specified date" % \
|
||||||
abs(days_old))
|
abs(days_old))
|
||||||
return 0
|
return False
|
||||||
|
|
||||||
|
|
||||||
def is_older_than_days(time_message, max_days):
|
def is_older_than_days(time_message, max_days):
|
||||||
|
@ -1023,13 +1023,13 @@ def is_older_than_days(time_message, max_days):
|
||||||
time_now = time.time()
|
time_now = time.time()
|
||||||
if time_message > time_now:
|
if time_message > time_now:
|
||||||
vprint("warning: message has date in the future")
|
vprint("warning: message has date in the future")
|
||||||
return 0
|
return False
|
||||||
secs_old_max = (max_days * 24 * 60 * 60)
|
secs_old_max = (max_days * 24 * 60 * 60)
|
||||||
days_old = (time_now - time_message) / 24 / 60 / 60
|
days_old = (time_now - time_message) / 24 / 60 / 60
|
||||||
vprint("message is %.2f days old" % days_old)
|
vprint("message is %.2f days old" % days_old)
|
||||||
if ((time_message + secs_old_max) < time_now):
|
if ((time_message + secs_old_max) < time_now):
|
||||||
return 1
|
return True
|
||||||
return 0
|
return False
|
||||||
|
|
||||||
def build_imap_filter():
|
def build_imap_filter():
|
||||||
"""Return an imap filter string"""
|
"""Return an imap filter string"""
|
||||||
|
|
|
@ -240,7 +240,7 @@ class TestTempMboxRemove(TestCaseInTempdir):
|
||||||
class TestOptionDefaults(unittest.TestCase):
|
class TestOptionDefaults(unittest.TestCase):
|
||||||
def testVerbose(self):
|
def testVerbose(self):
|
||||||
"""verbose should be off by default"""
|
"""verbose should be off by default"""
|
||||||
self.assertEqual(archivemail.options.verbose, 0)
|
self.assertEqual(archivemail.options.verbose, False)
|
||||||
|
|
||||||
def testDaysOldMax(self):
|
def testDaysOldMax(self):
|
||||||
"""default archival time should be 180 days"""
|
"""default archival time should be 180 days"""
|
||||||
|
@ -248,23 +248,23 @@ class TestOptionDefaults(unittest.TestCase):
|
||||||
|
|
||||||
def testQuiet(self):
|
def testQuiet(self):
|
||||||
"""quiet should be off by default"""
|
"""quiet should be off by default"""
|
||||||
self.assertEqual(archivemail.options.quiet, 0)
|
self.assertEqual(archivemail.options.quiet, False)
|
||||||
|
|
||||||
def testDeleteOldMail(self):
|
def testDeleteOldMail(self):
|
||||||
"""we should not delete old mail by default"""
|
"""we should not delete old mail by default"""
|
||||||
self.assertEqual(archivemail.options.delete_old_mail, 0)
|
self.assertEqual(archivemail.options.delete_old_mail, False)
|
||||||
|
|
||||||
def testNoCompress(self):
|
def testNoCompress(self):
|
||||||
"""no-compression should be off by default"""
|
"""no-compression should be off by default"""
|
||||||
self.assertEqual(archivemail.options.no_compress, 0)
|
self.assertEqual(archivemail.options.no_compress, False)
|
||||||
|
|
||||||
def testIncludeFlagged(self):
|
def testIncludeFlagged(self):
|
||||||
"""we should not archive flagged messages by default"""
|
"""we should not archive flagged messages by default"""
|
||||||
self.assertEqual(archivemail.options.include_flagged, 0)
|
self.assertEqual(archivemail.options.include_flagged, False)
|
||||||
|
|
||||||
def testPreserveUnread(self):
|
def testPreserveUnread(self):
|
||||||
"""we should not preserve unread messages by default"""
|
"""we should not preserve unread messages by default"""
|
||||||
self.assertEqual(archivemail.options.preserve_unread, 0)
|
self.assertEqual(archivemail.options.preserve_unread, False)
|
||||||
|
|
||||||
class TestOptionParser(unittest.TestCase):
|
class TestOptionParser(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -290,7 +290,7 @@ class TestOptionParser(unittest.TestCase):
|
||||||
"""--preserve-unread option is parsed correctly"""
|
"""--preserve-unread option is parsed correctly"""
|
||||||
archivemail.options.parse_args(["--preserve-unread"], "")
|
archivemail.options.parse_args(["--preserve-unread"], "")
|
||||||
assert archivemail.options.preserve_unread
|
assert archivemail.options.preserve_unread
|
||||||
archivemail.options.preserve_unread = 0
|
archivemail.options.preserve_unread = False
|
||||||
archivemail.options.parse_args(["-u"], "")
|
archivemail.options.parse_args(["-u"], "")
|
||||||
assert archivemail.options.preserve_unread
|
assert archivemail.options.preserve_unread
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ class TestOptionParser(unittest.TestCase):
|
||||||
"""--dry-run option is parsed correctly"""
|
"""--dry-run option is parsed correctly"""
|
||||||
archivemail.options.parse_args(["--dry-run"], "")
|
archivemail.options.parse_args(["--dry-run"], "")
|
||||||
assert archivemail.options.dry_run
|
assert archivemail.options.dry_run
|
||||||
archivemail.options.preserve_unread = 0
|
archivemail.options.preserve_unread = False
|
||||||
archivemail.options.parse_args(["-n"], "")
|
archivemail.options.parse_args(["-n"], "")
|
||||||
assert archivemail.options.dry_run
|
assert archivemail.options.dry_run
|
||||||
|
|
||||||
|
@ -403,8 +403,8 @@ class TestIsTooOld(unittest.TestCase):
|
||||||
|
|
||||||
class TestParseIMAPUrl(unittest.TestCase):
|
class TestParseIMAPUrl(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
archivemail.options.quiet = 1
|
archivemail.options.quiet = True
|
||||||
archivemail.options.verbose = 0
|
archivemail.options.verbose = False
|
||||||
archivemail.options.pwfile = None
|
archivemail.options.pwfile = None
|
||||||
|
|
||||||
urls_withoutpass = [
|
urls_withoutpass = [
|
||||||
|
@ -473,8 +473,8 @@ class TestParseIMAPUrl(unittest.TestCase):
|
||||||
archivemail.parse_imap_url, url)
|
archivemail.parse_imap_url, url)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
archivemail.options.quiet = 0
|
archivemail.options.quiet = False
|
||||||
archivemail.options.verbose = 0
|
archivemail.options.verbose = False
|
||||||
archivemail.options.pwfile = None
|
archivemail.options.pwfile = None
|
||||||
|
|
||||||
########## acceptance testing ###########
|
########## acceptance testing ###########
|
||||||
|
@ -557,7 +557,7 @@ class TestArchiveMbox(TestArchive):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.oldopts = copy.copy(archivemail.options)
|
self.oldopts = copy.copy(archivemail.options)
|
||||||
archivemail.options.quiet = 1
|
archivemail.options.quiet = True
|
||||||
super(TestArchiveMbox, self).setUp()
|
super(TestArchiveMbox, self).setUp()
|
||||||
|
|
||||||
def testOld(self):
|
def testOld(self):
|
||||||
|
@ -685,7 +685,7 @@ class TestArchiveMboxTimestamp(TestCaseInTempdir):
|
||||||
"""original mbox timestamps should always be preserved"""
|
"""original mbox timestamps should always be preserved"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestArchiveMboxTimestamp, self).setUp()
|
super(TestArchiveMboxTimestamp, self).setUp()
|
||||||
archivemail.options.quiet = 1
|
archivemail.options.quiet = True
|
||||||
self.mbox_name = make_mbox(messages=3, hours_old=(24 * 180))
|
self.mbox_name = make_mbox(messages=3, hours_old=(24 * 180))
|
||||||
self.mtime = os.path.getmtime(self.mbox_name) - 66
|
self.mtime = os.path.getmtime(self.mbox_name) - 66
|
||||||
self.atime = os.path.getatime(self.mbox_name) - 88
|
self.atime = os.path.getatime(self.mbox_name) - 88
|
||||||
|
@ -711,7 +711,7 @@ class TestArchiveMboxTimestamp(TestCaseInTempdir):
|
||||||
self.assertAlmostEqual(self.atime, new_atime, utimes_precision)
|
self.assertAlmostEqual(self.atime, new_atime, utimes_precision)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
archivemail.options.quiet = 0
|
archivemail.options.quiet = False
|
||||||
archivemail.options.days_old_max = 180
|
archivemail.options.days_old_max = 180
|
||||||
os.remove(self.mbox_name)
|
os.remove(self.mbox_name)
|
||||||
super(TestArchiveMboxTimestamp, self).tearDown()
|
super(TestArchiveMboxTimestamp, self).tearDown()
|
||||||
|
@ -719,8 +719,8 @@ class TestArchiveMboxTimestamp(TestCaseInTempdir):
|
||||||
|
|
||||||
class TestArchiveMboxAll(unittest.TestCase):
|
class TestArchiveMboxAll(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
archivemail.options.quiet = 1
|
archivemail.options.quiet = True
|
||||||
archivemail.options.archive_all = 1
|
archivemail.options.archive_all = True
|
||||||
|
|
||||||
def testNew(self):
|
def testNew(self):
|
||||||
"""new messages should be archived with --all"""
|
"""new messages should be archived with --all"""
|
||||||
|
@ -733,14 +733,14 @@ class TestArchiveMboxAll(unittest.TestCase):
|
||||||
assert archivemail.should_archive(self.msg)
|
assert archivemail.should_archive(self.msg)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
archivemail.options.quiet = 0
|
archivemail.options.quiet = False
|
||||||
archivemail.options.archive_all = 0
|
archivemail.options.archive_all = False
|
||||||
|
|
||||||
class TestArchiveMboxPreserveUnread(unittest.TestCase):
|
class TestArchiveMboxPreserveUnread(unittest.TestCase):
|
||||||
"""make sure the 'preserve_unread' option works"""
|
"""make sure the 'preserve_unread' option works"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
archivemail.options.quiet = 1
|
archivemail.options.quiet = True
|
||||||
archivemail.options.preserve_unread = 1
|
archivemail.options.preserve_unread = True
|
||||||
self.msg = make_message(hours_old=24*181, wantobj=True)
|
self.msg = make_message(hours_old=24*181, wantobj=True)
|
||||||
|
|
||||||
def testOldRead(self):
|
def testOldRead(self):
|
||||||
|
@ -754,15 +754,15 @@ class TestArchiveMboxPreserveUnread(unittest.TestCase):
|
||||||
assert not archivemail.should_archive(self.msg)
|
assert not archivemail.should_archive(self.msg)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
archivemail.options.quiet = 0
|
archivemail.options.quiet = False
|
||||||
archivemail.options.preserve_unread = 0
|
archivemail.options.preserve_unread = False
|
||||||
|
|
||||||
|
|
||||||
class TestArchiveMboxSuffix(unittest.TestCase):
|
class TestArchiveMboxSuffix(unittest.TestCase):
|
||||||
"""make sure the 'suffix' option works"""
|
"""make sure the 'suffix' option works"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.old_suffix = archivemail.options.archive_suffix
|
self.old_suffix = archivemail.options.archive_suffix
|
||||||
archivemail.options.quiet = 1
|
archivemail.options.quiet = True
|
||||||
|
|
||||||
def testSuffix(self):
|
def testSuffix(self):
|
||||||
"""archiving with specified --suffix arguments"""
|
"""archiving with specified --suffix arguments"""
|
||||||
|
@ -778,7 +778,7 @@ class TestArchiveMboxSuffix(unittest.TestCase):
|
||||||
archivemail.make_archive_name(mbox_name))
|
archivemail.make_archive_name(mbox_name))
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
archivemail.options.quiet = 0
|
archivemail.options.quiet = False
|
||||||
archivemail.options.archive_suffix = self.old_suffix
|
archivemail.options.archive_suffix = self.old_suffix
|
||||||
|
|
||||||
|
|
||||||
|
@ -786,8 +786,8 @@ class TestArchiveDryRun(TestArchive):
|
||||||
"""make sure the 'dry-run' option works"""
|
"""make sure the 'dry-run' option works"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestArchiveDryRun, self).setUp()
|
super(TestArchiveDryRun, self).setUp()
|
||||||
archivemail.options.quiet = 1
|
archivemail.options.quiet = True
|
||||||
archivemail.options.dry_run = 1
|
archivemail.options.dry_run = True
|
||||||
|
|
||||||
def testOld(self):
|
def testOld(self):
|
||||||
"""archiving an old mailbox with the 'dry-run' option"""
|
"""archiving an old mailbox with the 'dry-run' option"""
|
||||||
|
@ -796,8 +796,8 @@ class TestArchiveDryRun(TestArchive):
|
||||||
self.verify()
|
self.verify()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
archivemail.options.dry_run = 0
|
archivemail.options.dry_run = False
|
||||||
archivemail.options.quiet = 0
|
archivemail.options.quiet = False
|
||||||
super(TestArchiveDryRun, self).tearDown()
|
super(TestArchiveDryRun, self).tearDown()
|
||||||
|
|
||||||
|
|
||||||
|
@ -805,8 +805,8 @@ class TestArchiveDelete(TestArchive):
|
||||||
"""make sure the 'delete' option works"""
|
"""make sure the 'delete' option works"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestArchiveDelete, self).setUp()
|
super(TestArchiveDelete, self).setUp()
|
||||||
archivemail.options.quiet = 1
|
archivemail.options.quiet = True
|
||||||
archivemail.options.delete_old_mail = 1
|
archivemail.options.delete_old_mail = True
|
||||||
|
|
||||||
def testNew(self):
|
def testNew(self):
|
||||||
"""archiving a new mailbox with the 'delete' option"""
|
"""archiving a new mailbox with the 'delete' option"""
|
||||||
|
@ -827,8 +827,8 @@ class TestArchiveDelete(TestArchive):
|
||||||
self.verify()
|
self.verify()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
archivemail.options.delete_old_mail = 0
|
archivemail.options.delete_old_mail = False
|
||||||
archivemail.options.quiet = 0
|
archivemail.options.quiet = False
|
||||||
super(TestArchiveDelete, self).tearDown()
|
super(TestArchiveDelete, self).tearDown()
|
||||||
|
|
||||||
|
|
||||||
|
@ -836,8 +836,8 @@ class TestArchiveCopy(TestArchive):
|
||||||
"""make sure the 'copy' option works"""
|
"""make sure the 'copy' option works"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestArchiveCopy, self).setUp()
|
super(TestArchiveCopy, self).setUp()
|
||||||
archivemail.options.quiet = 1
|
archivemail.options.quiet = True
|
||||||
archivemail.options.copy_old_mail = 1
|
archivemail.options.copy_old_mail = True
|
||||||
|
|
||||||
def testNew(self):
|
def testNew(self):
|
||||||
"""archiving a new mailbox with the 'copy' option"""
|
"""archiving a new mailbox with the 'copy' option"""
|
||||||
|
@ -858,16 +858,16 @@ class TestArchiveCopy(TestArchive):
|
||||||
self.verify()
|
self.verify()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
archivemail.options.copy_old_mail = 0
|
archivemail.options.copy_old_mail = False
|
||||||
archivemail.options.quiet = 0
|
archivemail.options.quiet = False
|
||||||
super(TestArchiveCopy, self).tearDown()
|
super(TestArchiveCopy, self).tearDown()
|
||||||
|
|
||||||
|
|
||||||
class TestArchiveMboxFlagged(unittest.TestCase):
|
class TestArchiveMboxFlagged(unittest.TestCase):
|
||||||
"""make sure the 'include_flagged' option works"""
|
"""make sure the 'include_flagged' option works"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
archivemail.options.include_flagged = 0
|
archivemail.options.include_flagged = False
|
||||||
archivemail.options.quiet = 1
|
archivemail.options.quiet = True
|
||||||
|
|
||||||
def testOld(self):
|
def testOld(self):
|
||||||
"""by default, old flagged messages should not be archived"""
|
"""by default, old flagged messages should not be archived"""
|
||||||
|
@ -883,20 +883,20 @@ class TestArchiveMboxFlagged(unittest.TestCase):
|
||||||
|
|
||||||
def testIncludeFlaggedOld(self):
|
def testIncludeFlaggedOld(self):
|
||||||
"""old flagged messages should be archived with include_flagged"""
|
"""old flagged messages should be archived with include_flagged"""
|
||||||
archivemail.options.include_flagged = 1
|
archivemail.options.include_flagged = True
|
||||||
msg = make_message(default_headers={"X-Status": "F"},
|
msg = make_message(default_headers={"X-Status": "F"},
|
||||||
hours_old=24*181, wantobj=True)
|
hours_old=24*181, wantobj=True)
|
||||||
assert archivemail.should_archive(msg)
|
assert archivemail.should_archive(msg)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
archivemail.options.include_flagged = 0
|
archivemail.options.include_flagged = False
|
||||||
archivemail.options.quiet = 0
|
archivemail.options.quiet = False
|
||||||
|
|
||||||
|
|
||||||
class TestArchiveMboxOutputDir(unittest.TestCase):
|
class TestArchiveMboxOutputDir(unittest.TestCase):
|
||||||
"""make sure that the 'output-dir' option works"""
|
"""make sure that the 'output-dir' option works"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
archivemail.options.quiet = 1
|
archivemail.options.quiet = True
|
||||||
|
|
||||||
def testOld(self):
|
def testOld(self):
|
||||||
"""archiving an old mailbox with a sepecified output dir"""
|
"""archiving an old mailbox with a sepecified output dir"""
|
||||||
|
@ -906,7 +906,7 @@ class TestArchiveMboxOutputDir(unittest.TestCase):
|
||||||
self.assertEqual(dir, os.path.dirname(archive_dir))
|
self.assertEqual(dir, os.path.dirname(archive_dir))
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
archivemail.options.quiet = 0
|
archivemail.options.quiet = False
|
||||||
archivemail.options.output_dir = None
|
archivemail.options.output_dir = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -918,8 +918,8 @@ class TestArchiveMboxUncompressed(TestArchive):
|
||||||
copy_name = None
|
copy_name = None
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
archivemail.options.quiet = 1
|
archivemail.options.quiet = True
|
||||||
archivemail.options.no_compress = 1
|
archivemail.options.no_compress = True
|
||||||
super(TestArchiveMboxUncompressed, self).setUp()
|
super(TestArchiveMboxUncompressed, self).setUp()
|
||||||
|
|
||||||
def testOld(self):
|
def testOld(self):
|
||||||
|
@ -947,15 +947,15 @@ class TestArchiveMboxUncompressed(TestArchive):
|
||||||
self.verify()
|
self.verify()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
archivemail.options.quiet = 0
|
archivemail.options.quiet = False
|
||||||
archivemail.options.no_compress = 0
|
archivemail.options.no_compress = False
|
||||||
super(TestArchiveMboxUncompressed, self).tearDown()
|
super(TestArchiveMboxUncompressed, self).tearDown()
|
||||||
|
|
||||||
|
|
||||||
class TestArchiveSize(unittest.TestCase):
|
class TestArchiveSize(unittest.TestCase):
|
||||||
"""check that the 'size' argument works"""
|
"""check that the 'size' argument works"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
archivemail.options.quiet = 1
|
archivemail.options.quiet = True
|
||||||
msg_text = make_message(hours_old=24*181)
|
msg_text = make_message(hours_old=24*181)
|
||||||
self.msg_size = len(msg_text)
|
self.msg_size = len(msg_text)
|
||||||
fp = cStringIO.StringIO(msg_text)
|
fp = cStringIO.StringIO(msg_text)
|
||||||
|
@ -972,7 +972,7 @@ class TestArchiveSize(unittest.TestCase):
|
||||||
assert not archivemail.should_archive(self.msg)
|
assert not archivemail.should_archive(self.msg)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
archivemail.options.quiet = 0
|
archivemail.options.quiet = False
|
||||||
archivemail.options.min_size = None
|
archivemail.options.min_size = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -980,7 +980,7 @@ class TestArchiveMboxMode(TestCaseInTempdir):
|
||||||
"""file mode (permissions) of the original mbox should be preserved"""
|
"""file mode (permissions) of the original mbox should be preserved"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestArchiveMboxMode, self).setUp()
|
super(TestArchiveMboxMode, self).setUp()
|
||||||
archivemail.options.quiet = 1
|
archivemail.options.quiet = True
|
||||||
|
|
||||||
def testOld(self):
|
def testOld(self):
|
||||||
"""after archiving, the original mbox mode should be preserved"""
|
"""after archiving, the original mbox mode should be preserved"""
|
||||||
|
@ -1010,7 +1010,7 @@ class TestArchiveMboxMode(TestCaseInTempdir):
|
||||||
os.remove(self.mbox_name)
|
os.remove(self.mbox_name)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
archivemail.options.quiet = 0
|
archivemail.options.quiet = False
|
||||||
super(TestArchiveMboxMode, self).tearDown()
|
super(TestArchiveMboxMode, self).tearDown()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue