Merge branch 'ss/ui-remove-detector' into next

This commit is contained in:
Nicolas Sebrecht
2011-01-07 19:38:12 +01:00
3 changed files with 26 additions and 79 deletions

View File

@ -1,6 +1,5 @@
# UI module directory
# Copyright (C) 2002 John Goerzen
# <jgoerzen@complete.org>
# UI module
# Copyright (C) 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -16,23 +15,17 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
from offlineimap.ui.UIBase import getglobalui, setglobalui
from offlineimap.ui import TTY, Noninteractive, Machine
import UIBase, Blinkenlights
UI_LIST = {'TTY.TTYUI': TTY.TTYUI,
'Noninteractive.Basic': Noninteractive.Basic,
'Noninteractive.Quiet': Noninteractive.Quiet,
'Machine.MachineUI': Machine.MachineUI}
#add Blinkenlights UI if it imports correctly (curses installed)
try:
import TTY
from offlineimap.ui import Curses
UI_LIST['Curses.Blinkenlights'] = Curses.Blinkenlights
except ImportError:
pass
try:
import curses
except ImportError:
pass
else:
import Curses
import Noninteractive
import Machine
# Must be last
import detector

View File

@ -1,54 +0,0 @@
# UI base class
# Copyright (C) 2002 John Goerzen
# <jgoerzen@complete.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import offlineimap.ui
import sys
DEFAULT_UI_LIST = ('Curses.Blinkenlights', 'TTY.TTYUI',
'Noninteractive.Basic', 'Noninteractive.Quiet',
'Machine.MachineUI')
def findUI(config, chosenUI=None):
uistrlist = list(DEFAULT_UI_LIST)
namespace={}
for ui in dir(offlineimap.ui):
if ui.startswith('_') or ui in ('detector', 'UIBase'):
continue
namespace[ui]=getattr(offlineimap.ui, ui)
if chosenUI is not None:
uistrlist = [chosenUI]
elif config.has_option("general", "ui"):
uistrlist = config.get("general", "ui").replace(" ", "").split(",")
for uistr in uistrlist:
uimod = getUImod(uistr, config.getlocaleval(), namespace)
if uimod:
uiinstance = uimod(config)
if uiinstance.isusable():
return uiinstance
sys.stderr.write("ERROR: No UIs were found usable!\n")
sys.exit(200)
def getUImod(uistr, localeval, namespace):
try:
uimod = localeval.eval(uistr, namespace)
except (AttributeError, NameError), e:
#raise
return None
return uimod