From 4e28c7c93fdb6dd105ce482ac9b8d4d78d2da35b Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Sun, 6 Mar 2011 11:04:46 +0100 Subject: [PATCH] Allow to use nicer UI names The previous ui names were pretty unwieldy. Is it TTYUI.TTY or TTY.TTYUI? Do I have to use capitals and where? Simplify the names by making them case insensitive and by dropping everything before the dot. So "Curses.Blinkenlights" can now be invoked as "blinkenlights" or "BLINKENLIGHTS". The old names will still work just fine so the transition should be smooth. We issue a warning that the long names are deprecated. Document in offlineimap.conf that we don't accept lists of fallback UIs, but only one UI option (this was already the case before this commit but still wrongly documented). The list of accepted ui names is: ttyui (default), basic, quiet, machineui, blinkenlights Signed-off-by: Sebastian Spaeth Signed-off-by: Nicolas Sebrecht --- Changelog.draft.rst | 3 +++ docs/MANUAL.rst | 52 ++++++++++++++++++-------------------- offlineimap.conf | 18 ++++++------- offlineimap/init.py | 12 ++++++--- offlineimap/ui/__init__.py | 10 ++++---- 5 files changed, 50 insertions(+), 45 deletions(-) diff --git a/Changelog.draft.rst b/Changelog.draft.rst index f68d747..a3c70ec 100644 --- a/Changelog.draft.rst +++ b/Changelog.draft.rst @@ -23,6 +23,9 @@ Changes * Makefile use magic to find the version number. * Rework the repository module +* Change UI names to Blinkenlights,TTYUI,Basic,Quiet,MachineUI. + Old names will still work, but are deprecated. + Document that we don't accept a list of UIs anymore. Bug Fixes --------- diff --git a/docs/MANUAL.rst b/docs/MANUAL.rst index 67fa383..9ef4eea 100644 --- a/docs/MANUAL.rst +++ b/docs/MANUAL.rst @@ -134,30 +134,29 @@ OPTIONS Specifies an alternative user interface module to use. This overrides the default specified in the configuration file. The pre-defined options are - listed in the User Interfaces section. + listed in the User Interfaces section. The interface name is case insensitive. User Interfaces =============== -OfflineIMAP has a pluggable user interface system that lets you choose how the -program communicates information to you. There are two graphical interfaces, -two terminal interfaces, and two noninteractive interfaces suitable for -scripting or logging purposes. The ui option in the configuration file -specifies user interface preferences. The -u command-line option can override -the configuration file setting. The available values for the configuration file -or command-line are described in this section. +OfflineIMAP has various user interfaces that let you choose how the +program communicates information to you. The 'ui' option in the +configuration file specifies the user interface. The -u command-line +option overrides the configuration file setting. The available values +for the configuration file or command-line are described in this +section. -Curses.Blinkenlights --------------------- +Blinkenlights +--------------- -Curses.Blinkenlights is an interface designed to be sleek, fun to watch, and +Blinkenlights is an interface designed to be sleek, fun to watch, and informative of the overall picture of what OfflineIMAP is doing. I consider it to be the best general-purpose interface in OfflineIMAP. -Curses.Blinkenlights contains a row of "LEDs" with command buttons and a log. +Blinkenlights contains a row of "LEDs" with command buttons and a log. The log shows more detail about what is happening and is color-coded to match the color of the lights. @@ -228,18 +227,18 @@ English-speaking world. One version ran in its entirety as follows: | pockets muss; relaxen und watchen das blinkenlichten. -TTY.TTYUI +TTYUI --------- -TTY.TTYUI interface is for people running in basic, non-color terminals. It +TTYUI interface is for people running in basic, non-color terminals. It prints out basic status messages and is generally friendly to use on a console or xterm. -Noninteractive.Basic +Basic -------------------- -Noninteractive.Basic is designed for situations in which OfflineIMAP will be run +Basic is designed for situations in which OfflineIMAP will be run non-attended and the status of its execution will be logged. You might use it, for instance, to have the system run automatically and e-mail you the results of the synchronization. This user interface is not capable of reading a password @@ -247,20 +246,19 @@ from the keyboard; account passwords must be specified using one of the configuration file options. -Noninteractive.Quiet --------------------- +Quiet +----- -Noninteractive.Quiet is designed for non-attended running in situations where -normal status messages are not desired. It will output nothing except errors -and serious warnings. Like Noninteractive.Basic, this user interface is not -capable of reading a password from the keyboard; account passwords must be -specified using one of the configuration file options. +Quiet is designed for non-attended running in situations where normal +status messages are not desired. It will output nothing except errors +and serious warnings. Like Noninteractive.Basic, this user interface is +not capable of reading a password from the keyboard; account passwords +must be specified using one of the configuration file options. +MachineUI +--------- -Machine.MachineUI ------------------ - -Machine.MachineUI generates output in a machine-parsable format. It is designed +MachineUI generates output in a machine-parsable format. It is designed for other programs that will interface to OfflineIMAP. diff --git a/offlineimap.conf b/offlineimap.conf index 72a3fa8..6032fd8 100644 --- a/offlineimap.conf +++ b/offlineimap.conf @@ -55,19 +55,17 @@ maxsyncaccounts = 1 # fails, the second, and so forth. # # The pre-defined options are: -# Curses.Blinkenlights -- A text-based (terminal) interface similar to -# Tk.Blinkenlights -# TTY.TTYUI -- a text-based (terminal) interface -# Noninteractive.Basic -- Noninteractive interface suitable for cronning -# Noninteractive.Quiet -- Noninteractive interface, generates no output -# except for errors. -# Machine.MachineUI -- Interactive interface suitable for machine -# parsing. +# Blinkenlights -- A fancy (terminal) interface +# TTYUI -- a text-based (terminal) interface +# Basic -- Noninteractive interface suitable for cron'ing +# Quiet -- Noninteractive interface, generates no output +# except for errors. +# MachineUI -- Interactive interface suitable for machine +# parsing. # # You can override this with a command-line option -u. -ui = Curses.Blinkenlights, TTY.TTYUI, - Noninteractive.Basic, Noninteractive.Quiet +ui = Blinkenlights # If you try to synchronize messages to a read-only folder, # OfflineIMAP will generate a warning. If you want to suppress these diff --git a/offlineimap/init.py b/offlineimap/init.py index 8aebb23..38c68b4 100644 --- a/offlineimap/init.py +++ b/offlineimap/init.py @@ -187,12 +187,18 @@ class OfflineImap: section = "general" config.set(section, key, value) - #init the ui, cmd line option overrides config file - ui_type = config.getdefault('general','ui', 'TTY.TTYUI') + #which ui to use? cmd line option overrides config file + ui_type = config.getdefault('general','ui', 'ttyui') if options.interface != None: ui_type = options.interface + if '.' in ui_type: + #transform Curses.Blinkenlights -> Blinkenlights + ui_type = ui_type.split('.')[-1] + logging.warning('Using old interface name, consider using one ' + 'of %s' % ', '.join(UI_LIST.keys())) try: - ui = UI_LIST[ui_type](config) + # create the ui class + ui = UI_LIST[ui_type.lower()](config) except KeyError: logging.error("UI '%s' does not exist, choose one of: %s" % \ (ui_type,', '.join(UI_LIST.keys()))) diff --git a/offlineimap/ui/__init__.py b/offlineimap/ui/__init__.py index 83d81c6..102cbfd 100644 --- a/offlineimap/ui/__init__.py +++ b/offlineimap/ui/__init__.py @@ -18,14 +18,14 @@ from offlineimap.ui.UIBase import getglobalui, setglobalui from offlineimap.ui import TTY, Noninteractive, Machine -UI_LIST = {'TTY.TTYUI': TTY.TTYUI, - 'Noninteractive.Basic': Noninteractive.Basic, - 'Noninteractive.Quiet': Noninteractive.Quiet, - 'Machine.MachineUI': Machine.MachineUI} +UI_LIST = {'ttyui': TTY.TTYUI, + 'basic': Noninteractive.Basic, + 'quiet': Noninteractive.Quiet, + 'machineui': Machine.MachineUI} #add Blinkenlights UI if it imports correctly (curses installed) try: from offlineimap.ui import Curses - UI_LIST['Curses.Blinkenlights'] = Curses.Blinkenlights + UI_LIST['blinkenlights'] = Curses.Blinkenlights except ImportError: pass