[Reportbug-commits] r646 - in trunk (5 files)

morph-guest at users.alioth.debian.org morph-guest at users.alioth.debian.org
Fri Sep 5 22:52:53 UTC 2008


    Date: Friday, September 5, 2008 @ 22:52:52
  Author: morph-guest
Revision: 646

AVAILABLE_UIS is now a dict; added ui.getUI; clean-up and fixes

Modified:
  trunk/bin/querybts
  trunk/bin/reportbug
  trunk/debian/changelog
  trunk/reportbug/ui/__init__.py
  trunk/reportbug/utils.py

Modified: trunk/bin/querybts
===================================================================
--- trunk/bin/querybts	2008-09-04 17:35:47 UTC (rev 645)
+++ trunk/bin/querybts	2008-09-05 22:52:52 UTC (rev 646)
@@ -40,10 +40,10 @@
 from reportbug.ui import AVAILABLE_UIS
 
 try:
-    import reportbug.ui.newt as ui
+    import reportbug.ui.newt_ui as ui
     ui_mode = 'newt'
 except:
-    import reportbug.ui.text as ui
+    import reportbug.ui.text_ui as ui
     ui_mode = 'text'
 
 VERSION = "querybts ##VERSION##"
@@ -106,12 +106,11 @@
         elif option in ('-s', '--source'):
             source = True
         elif option in ('-u', '--ui', '--interface'):
-            if arg in AVAILABLE_UIS:
+            if arg in AVAILABLE_UIS.keys():
                 interface = arg
             elif arg == 'help':
-                print 'Permitted arguments to --ui:\n'\
-                      ' text: line-oriented text mode\n'\
-                      ' newt: screen-oriented text mode'
+                print 'Allowed arguments to --ui:\n'
+                for k in AVAILABLE_UIS.keys(): print ' %s: %s' % (k, AVAILABLE_UIS[k])
                 sys.exit(0)
             else:
                 print "Ignoring unknown user interface %s\n" % arg

Modified: trunk/bin/reportbug
===================================================================
--- trunk/bin/reportbug	2008-09-04 17:35:47 UTC (rev 645)
+++ trunk/bin/reportbug	2008-09-05 22:52:52 UTC (rev 646)
@@ -61,9 +61,11 @@
 import reportbug.ui.text_ui as ui
 
 from reportbug.ui import (
-    UIS, AVAILABLE_UIS
+    UIS, AVAILABLE_UIS, getUI
     )
 
+#ui = getUI('text')
+
 try:
     gettext.install('reportbug')
 except IOError:
@@ -433,17 +435,11 @@
     mode = ui.menu('Please choose the default operating mode for reportbug.',
                    utils.MODES, 'Select mode: ', options.mode,
                    order=utils.MODELIST)
-    uis = dict()
-    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,
-            'Select interface: ', options.interface)
-    else:
-        interface = 'text'
 
+    interface = ui.menu(
+        'Please choose the default interface for reportbug.', AVAILABLE_UIS,
+        'Select interface: ', options.interface)
+
     online = ui.yes_no('Will reportbug often have direct '
                        'Internet access?  (You should answer yes to this '
                        'question unless you know what you are doing and '
@@ -762,7 +758,7 @@
     parser.add_option('-u', '--interface', '--ui', action='callback',
                       callback=verify_option, type='string', dest='interface',
                       callback_args=('Valid user interfaces',
-                                     AVAILABLE_UIS),
+                                     AVAILABLE_UIS.keys()),
                       help='choose which user interface to use')
     parser.add_option('-Q', '--query-only', action='store_true',
                       dest='queryonly', help='only query the BTS')
@@ -826,13 +822,6 @@
     sys.argv = sys.argv[:1] + list(args)
     if options.interface:
         interface = options.interface
-        if interface in ('gnome', 'newt'):
-            ui.long_message("The %s interface is not supported.  Unless you "
-                            "are debugging reportbug, please do not use it.  "
-                            "If you are debugging reportbug, please DO NOT "
-                            "file bugs more serious than 'normal' that "
-                            "indicate problems with this interface.\n",
-                            interface)
 
         iface = '%(interface)s_ui' % vars()
         try:

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2008-09-04 17:35:47 UTC (rev 645)
+++ trunk/debian/changelog	2008-09-05 22:52:52 UTC (rev 646)
@@ -45,7 +45,7 @@
   * reportbug/debianbts.py
     - added buildd.emdebian.org and debian-i18n pseudo-packages
 
- -- Sandro Tosi <matrixhasu at gmail.com>  Thu, 04 Sep 2008 19:26:24 +0200
+ -- Sandro Tosi <matrixhasu at gmail.com>  Sat, 06 Sep 2008 00:50:37 +0200
 
 reportbug (3.45) unstable; urgency=low
 

Modified: trunk/reportbug/ui/__init__.py
===================================================================
--- trunk/reportbug/ui/__init__.py	2008-09-04 17:35:47 UTC (rev 645)
+++ trunk/reportbug/ui/__init__.py	2008-09-05 22:52:52 UTC (rev 646)
@@ -30,8 +30,12 @@
        'newt': 'A newt user interface',
        'gtk2': 'A graphical (GTK+) user interface'}
 
-AVAILABLE_UIS = []
+# Only the available UIs
+AVAILABLE_UIS = {}
 
+# List of already loaded ui, we can give back to requestors
+__LOADED_UIS = {}
+
 for uis in UIS.keys():
     try:
         # let's try to import the ui...
@@ -39,7 +43,19 @@
         # ... 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)
+        AVAILABLE_UIS[uis] = UIS[uis]
+        __LOADED_UIS[uis] = ui
     except:
         # we can't import uis, so just skip it
         pass
+
+
+def getUI(ui):
+    """Returns the requested UI, or default to text if not available"""
+
+    if __LOADED_UIS.has_key(ui):
+        print "loading %s" % ui
+        return __LOADED_UIS[ui]
+    else:
+        print "defaulting to text ui"
+        return __LOADED_UIS['text']

Modified: trunk/reportbug/utils.py
===================================================================
--- trunk/reportbug/utils.py	2008-09-04 17:35:47 UTC (rev 645)
+++ trunk/reportbug/utils.py	2008-09-05 22:52:52 UTC (rev 646)
@@ -48,24 +48,6 @@
 
 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 '
          'things that a moderately sophisticated user would be expected to '
@@ -813,7 +795,7 @@
                         args['sign'] = ''
                 elif token == 'ui':
                     token = lex.get_token().lower()
-                    if token in AVAILABLE_UIS:
+                    if token in AVAILABLE_UIS.keys():
                         args['interface'] = token
                 elif token == 'mode':
                     arg = lex.get_token().lower()




More information about the Reportbug-commits mailing list