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

morph-guest at users.alioth.debian.org morph-guest at users.alioth.debian.org
Mon Sep 1 21:36:24 UTC 2008


    Date: Monday, September 1, 2008 @ 21:36:23
  Author: morph-guest
Revision: 642

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

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-08-31 22:54:15 UTC (rev 641)
+++ trunk/bin/querybts	2008-09-01 21:36:23 UTC (rev 642)
@@ -37,6 +37,8 @@
 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 @@
         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'\

Modified: trunk/bin/reportbug
===================================================================
--- trunk/bin/reportbug	2008-08-31 22:54:15 UTC (rev 641)
+++ trunk/bin/reportbug	2008-09-01 21:36:23 UTC (rev 642)
@@ -60,6 +60,10 @@
 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 @@
                    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 @@
     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')

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2008-08-31 22:54:15 UTC (rev 641)
+++ trunk/debian/changelog	2008-09-01 21:36:23 UTC (rev 642)
@@ -26,8 +26,12 @@
     - 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 at gmail.com>  Mon, 01 Sep 2008 00:45:25 +0200
+ -- Sandro Tosi <matrixhasu at gmail.com>  Mon, 01 Sep 2008 22:40:41 +0200
 
 reportbug (3.45) unstable; urgency=low
 

Modified: trunk/reportbug/ui/__init__.py
===================================================================
--- trunk/reportbug/ui/__init__.py	2008-08-31 22:54:15 UTC (rev 641)
+++ trunk/reportbug/ui/__init__.py	2008-09-01 21:36:23 UTC (rev 642)
@@ -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

Modified: trunk/reportbug/utils.py
===================================================================
--- trunk/reportbug/utils.py	2008-08-31 22:54:15 UTC (rev 641)
+++ trunk/reportbug/utils.py	2008-09-01 21:36:23 UTC (rev 642)
@@ -46,24 +46,26 @@
 PSEUDOHEADERS = ('Package', 'Version', 'Severity', 'File', 'Tags',
                  'Justification', 'Followup-For', 'Owner', 'User', 'Usertags')
 
-AVAILABLE_UIS = ['text']
+from reportbug.ui import AVAILABLE_UIS
 
-try:
-    import ui.urwid_ui
-    AVAILABLE_UIS.append('urwid')
-except:
-    pass
+#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'}
 
-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 '




More information about the Reportbug-commits mailing list