]>
code.delx.au - offlineimap/blob - offlineimap/ui/detector.py
2 # Copyright (C) 2002 John Goerzen
3 # <jgoerzen@complete.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 def findUI(config
, chosenUI
=None):
23 uistrlist
= ['Tk.Blinkenlights', 'Tk.VerboseUI',
24 'Curses.Blinkenlights', 'TTY.TTYUI',
25 'Noninteractive.Basic', 'Noninteractive.Quiet']
27 for ui
in dir(offlineimap
.ui
):
28 if ui
.startswith('_') or ui
=='detector':
30 namespace
[ui
]=getattr(offlineimap
.ui
, ui
)
32 if chosenUI
is not None:
33 uistrlist
= [chosenUI
]
34 elif config
.has_option("general", "ui"):
35 uistrlist
= config
.get("general", "ui").replace(" ", "").split(",")
37 for uistr
in uistrlist
:
38 uimod
= getUImod(uistr
, config
.getlocaleval(), namespace
)
40 uiinstance
= uimod(config
)
41 if uiinstance
.isusable():
43 sys
.stderr
.write("ERROR: No UIs were found usable!\n")
46 def getUImod(uistr
, localeval
, namespace
):
48 uimod
= localeval
.eval(uistr
, namespace
)
49 except (AttributeError, NameError), e
: