Create global instance of command-line options

This eases testing of option values inside the code.  This instance
is implemented as the read-only copy of the obtained 'options' object,
so callers won't be able to modify its contents.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
This commit is contained in:
Eygene Ryabinkin
2013-02-05 07:49:56 +04:00
parent 5c842c01bd
commit f4140cbbed
7 changed files with 136 additions and 5 deletions

View File

@ -25,6 +25,7 @@ import logging
from optparse import OptionParser
import offlineimap
from offlineimap import accounts, threadutil, syncmaster
from offlineimap import globals
from offlineimap.error import OfflineImapError
from offlineimap.ui import UI_LIST, setglobalui, getglobalui
from offlineimap.CustomConfig import CustomConfigParser
@ -161,6 +162,7 @@ class OfflineImap:
", ".join(UI_LIST.keys()))
(options, args) = parser.parse_args()
globals.set_options (options)
#read in configuration file
configfilename = os.path.expanduser(options.configfile)
@ -251,9 +253,6 @@ class OfflineImap:
if type.lower() == 'imap':
imaplib.Debug = 5
# XXX: can we avoid introducing fake configuration item?
config.set_if_not_exists('general', 'single-thread', 'True' if options.singlethreading else 'False')
if options.runonce:
# FIXME: maybe need a better
for section in accounts.getaccountlist(config):