Browse Source

move UIs identification to ui/__init__.py (where it belongs)

suites/jessie-proposed-backports
Sandro Tosi 14 years ago
parent
commit
1f71cd3f52
  1. 4
      bin/querybts
  2. 12
      bin/reportbug
  3. 6
      debian/changelog
  4. 22
      reportbug/ui/__init__.py
  5. 36
      reportbug/utils.py

4
bin/querybts

@ -37,6 +37,8 @@ from reportbug.exceptions import (
from reportbug import debianbts
from reportbug import urlutils
from reportbug.ui import AVAILABLE_UIS
try:
import reportbug.ui.newt as ui
ui_mode = 'newt'
@ -104,7 +106,7 @@ def main():
elif option in ('-s', '--source'):
source = True
elif option in ('-u', '--ui', '--interface'):
if arg in utils.AVAILABLE_UIS:
if arg in AVAILABLE_UIS:
interface = arg
elif arg == 'help':
print 'Permitted arguments to --ui:\n'\

12
bin/reportbug

@ -60,6 +60,10 @@ from reportbug import debianbts
from reportbug import checkbuildd
import reportbug.ui.text_ui as ui
from reportbug.ui import (
UIS, AVAILABLE_UIS
)
try:
gettext.install('reportbug')
except IOError:
@ -430,9 +434,9 @@ def offer_configuration(options):
utils.MODES, 'Select mode: ', options.mode,
order=utils.MODELIST)
uis = dict()
for i in utils.AVAILABLE_UIS:
if (i in utils.UIS) and i != 'newt':
uis[i] = utils.UIS[i]
for i in AVAILABLE_UIS:
if (i in UIS) and i != 'newt':
uis[i] = UIS[i]
if len(uis) > 1:
interface = ui.menu(
'Please choose the default interface for reportbug.', uis,
@ -758,7 +762,7 @@ def main():
parser.add_option('-u', '--interface', '--ui', action='callback',
callback=verify_option, type='string', dest='interface',
callback_args=('Valid user interfaces',
utils.AVAILABLE_UIS),
AVAILABLE_UIS),
help='choose which user interface to use')
parser.add_option('-Q', '--query-only', action='store_true',
dest='queryonly', help='only query the BTS')

6
debian/changelog

@ -26,8 +26,12 @@ reportbug (3.99.0) UNRELEASED; urgency=low
- reportbug/ui/text_ui.py
+ disabled utils.NEWBIELINE check to avoid circular import between text
and utils ******** WE NEED TO FIND A SOLUTION TO THIS **********
- reportbug/{utils.py,ui/__init__.py}
+ moved UIs list to ui.__init__, where it belongs; Closes: #497024
- bin/{querybts,reportbug}
- changed for new UIs list location
-- Sandro Tosi <matrixhasu@gmail.com> Mon, 01 Sep 2008 00:45:25 +0200
-- Sandro Tosi <matrixhasu@gmail.com> Mon, 01 Sep 2008 22:40:41 +0200
reportbug (3.45) unstable; urgency=low

22
reportbug/ui/__init__.py

@ -22,4 +22,24 @@
#
# $Id: reportbug.py,v 1.35.2.24 2008-04-18 05:38:28 lawrencc Exp $
__all__ = ['text', 'urwid']
__all__ = ['text_ui', 'urwid_ui', 'newt_ui', 'gtk2_ui']
UIS = {'text': 'A text-oriented console user interface',
'urwid': 'A menu-based console user interface',
'newt': 'A newt user interface',
'gtk2': 'A graphical (GTK+) user interface'}
AVAILABLE_UIS = []
for uis in UIS.keys():
try:
# let's try to import the ui...
ui_module = __import__('reportbug.ui', fromlist=[uis+'_ui'])
# ... and check if it's really imported
ui = getattr(ui_module, uis+'_ui')
# then we can finally add it to AVAILABLE_UIS
AVAILABLE_UIS.append(uis)
except:
# we can't import uis, so just skip it
pass

36
reportbug/utils.py

@ -46,23 +46,25 @@ STATUSDB = os.path.join(DPKGLIB, 'status')
PSEUDOHEADERS = ('Package', 'Version', 'Severity', 'File', 'Tags',
'Justification', 'Followup-For', 'Owner', 'User', 'Usertags')
AVAILABLE_UIS = ['text']
try:
import ui.urwid_ui
AVAILABLE_UIS.append('urwid')
except:
pass
try:
import ui.gnome2
AVAILABLE_UIS.append('gnome2')
except:
pass
UIS = {'text': 'A text-oriented console interface',
'urwid': 'A menu-based console interface',
'gnome2': 'A graphical (Gnome 2) interface'}
from reportbug.ui import AVAILABLE_UIS
#AVAILABLE_UIS = ['text']
#
#try:
# import ui.urwid_ui
# AVAILABLE_UIS.append('urwid')
#except:
# pass
#
#try:
# import ui.gnome2
# AVAILABLE_UIS.append('gnome2')
#except:
# pass
#
#UIS = {'text': 'A text-oriented console interface',
# 'urwid': 'A menu-based console interface',
# 'gnome2': 'A graphical (Gnome 2) interface'}
MODES = {'novice': 'Offer simple prompts, bypassing technical questions.',
'standard': 'Offer more extensive prompts, including asking about '

Loading…
Cancel
Save