]>
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 DEFAULT_UI_LIST
= ('Curses.Blinkenlights', 'TTY.TTYUI',
23 'Noninteractive.Basic', 'Noninteractive.Quiet',
26 def findUI(config
, chosenUI
=None):
27 uistrlist
= list(DEFAULT_UI_LIST
)
29 for ui
in dir(offlineimap
.ui
):
30 if ui
.startswith('_') or ui
in ('detector', 'UIBase'):
32 namespace
[ui
]=getattr(offlineimap
.ui
, ui
)
34 if chosenUI
is not None:
35 uistrlist
= [chosenUI
]
36 elif config
.has_option("general", "ui"):
37 uistrlist
= config
.get("general", "ui").replace(" ", "").split(",")
39 for uistr
in uistrlist
:
40 uimod
= getUImod(uistr
, config
.getlocaleval(), namespace
)
42 uiinstance
= uimod(config
)
43 if uiinstance
.isusable():
45 sys
.stderr
.write("ERROR: No UIs were found usable!\n")
48 def getUImod(uistr
, localeval
, namespace
):
50 uimod
= localeval
.eval(uistr
, namespace
)
51 except (AttributeError, NameError), e
: