[GRASS-SVN] r30365 - in grass/trunk/gui/wxpython: . gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Feb 26 16:20:43 EST 2008


Author: martinl
Date: 2008-02-26 16:20:43 -0500 (Tue, 26 Feb 2008)
New Revision: 30365

Modified:
   grass/trunk/gui/wxpython/gis_set.py
   grass/trunk/gui/wxpython/gui_modules/dbm.py
   grass/trunk/gui/wxpython/gui_modules/digit.py
   grass/trunk/gui/wxpython/gui_modules/gcmd.py
   grass/trunk/gui/wxpython/gui_modules/location_wizard.py
   grass/trunk/gui/wxpython/gui_modules/menuform.py
   grass/trunk/gui/wxpython/gui_modules/render.py
   grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: message cleaning, use named arguments

Modified: grass/trunk/gui/wxpython/gis_set.py
===================================================================
--- grass/trunk/gui/wxpython/gis_set.py	2008-02-26 20:36:32 UTC (rev 30364)
+++ grass/trunk/gui/wxpython/gis_set.py	2008-02-26 21:20:43 UTC (rev 30365)
@@ -451,10 +451,11 @@
         location = self.listOfLocations[self.lblocations.GetSelection()]
         mapset   = self.listOfMapsets[self.lbmapsets.GetSelection()]
 
-        dlg = wx.MessageDialog(parent=self, message=_("Do you want to continue with deleting mapset <%s> "
-                                                      "from location <%s>?\n\n"
+        dlg = wx.MessageDialog(parent=self, message=_("Do you want to continue with deleting mapset <%(mapset)s> "
+                                                      "from location <%(location)s>?\n\n"
                                                       "ALL MAPS included in this mapset will be "
-                                                      "PERMANENTLY DELETED!") % (mapset, location),
+                                                      "PERMANENTLY DELETED!") % {'mapset' : mapset,
+                                                                                 'location' : location},
                                caption=_("Delete selected mapset"),
                                style=wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
 

Modified: grass/trunk/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/dbm.py	2008-02-26 20:36:32 UTC (rev 30364)
+++ grass/trunk/gui/wxpython/gui_modules/dbm.py	2008-02-26 21:20:43 UTC (rev 30365)
@@ -490,7 +490,7 @@
             panel = wx.Panel(parent=self.browsePage, id=wx.ID_ANY)
             self.layerPage[layer] = {'browsePage': panel.GetId()}
 
-            self.browsePage.AddPage(page=panel, text=_(" %s %d ") % (_("Layer"), layer))
+            self.browsePage.AddPage(page=panel, text=" %s %d " % (_("Layer"), layer))
 
             pageSizer = wx.BoxSizer(wx.VERTICAL)
 
@@ -630,7 +630,7 @@
 
             panel = wx.Panel(parent=self.manageTablePage, id=wx.ID_ANY)
             self.layerPage[layer]['tablePage'] = panel.GetId()
-            self.manageTablePage.AddPage(page=panel, text=_(" %s %d ") % (_("Layer"), layer))
+            self.manageTablePage.AddPage(page=panel, text=" %s %d " % (_("Layer"), layer))
 
             pageSizer = wx.BoxSizer(wx.VERTICAL)
 
@@ -1073,9 +1073,9 @@
                     try:
                         values[i] = list.columns[columnName[i]]['ctype'] (values[i])
                     except:
-                        raise ValueError(_("Casting value '%s' to %s failed.") % \
-                                             (str(values[i]),
-                                              list.columns[columnName[i]]['type']))
+                        raise ValueError(_("Casting value '%(value)s' to %(type)s failed.") % 
+                                         {'value' : str(values[i]),
+                                          'type' : list.columns[columnName[i]]['type']})
                     columnsString += '%s,' % columnName[i]
                     if list.columns[columnName[i]]['ctype'] == str:
                         valuesString += "'%s'," % values[i]
@@ -1084,8 +1084,8 @@
 
             except ValueError, err:
                 wx.MessageBox(parent=self,
-                              message=_("Unable to insert new record.%s"
-                                        "%s") % (os.linesep, err),
+                              message="%s%s%s" % (_("Unable to insert new record."),
+                                                    os.linesep, err),
                               caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
                 return
 
@@ -1170,9 +1170,9 @@
                                 list.itemDataMap[item][idx] = \
                                     list.columns[columnName[i]]['ctype'] (values[i])
                             except:
-                                raise ValueError(_("Casting value '%s' to %s failed.") % \
-                                                     (str(values[i]),
-                                                      list.columns[columnName[i]]['type']))
+                                raise ValueError(_("Casting value '%(value)s' to %(type)s failed.") % \
+                                                     {'value' : str(values[i]),
+                                                      'type' : list.columns[columnName[i]]['type']})
 
                             if list.columns[columnName[i]]['ctype'] == str:
                                 updateString += "%s='%s'," % (columnName[i], values[i])
@@ -1183,8 +1183,8 @@
 
             except ValueError, err:
                 wx.MessageBox(parent=self,
-                              message=_("Unable to update existing record.%s"
-                                        "%s") % (os.linesep, err),
+                              message="%s%s%s" % (_("Unable to update existing record."),
+                                                  os.linesep, err),
                               caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
                 return
 
@@ -1271,9 +1271,10 @@
             if item > -1:
                 if list.FindItem(start=-1, str=nameTo) > -1:
                     wx.MessageBox(parent=self,
-                                  message=_("Unable to rename column <%s>. "
-                                            "Column <%s> already exists in the table <%s>.") % \
-                                  (name, nameTo, self.mapDBInfo.layers[self.layer]["table"]),
+                                  message=_("Unable to rename column <%(column)s>. "
+                                            "Column <%(columnTo)s> already exists in the table <%(table)s>.") % \
+                                      {'column' : name, 'columnTo' : nameTo,
+                                       'table' : self.mapDBInfo.layers[self.layer]["table"]},
                                   caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
                 else:
                     list.SetItemText(item, nameTo)
@@ -1285,8 +1286,8 @@
             else:
                 wx.MessageBox(parent=self,
                               message=_("Unable to rename column. "
-                                        "Column <%s> doesn't exist in the table <%s>.") % \
-                                  (name, self.mapDBInfo.layers[self.layer]["table"]),
+                                        "Column <%(column)s> doesn't exist in the table <%(table)s>.") % 
+                              {'column' : name, 'table' : self.mapDBInfo.layers[self.layer]["table"]},
                               caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
 
         event.Skip()
@@ -1370,8 +1371,8 @@
             # check for duplicate items
             if list.FindItem(start=-1, str=name) > -1:
                 wx.MessageBox(parent=self,
-                              message=_("Column <%s> already exists in table <%s>.") % \
-                                  (name, self.mapDBInfo.layers[self.layer]["table"]),
+                              message=_("Column <%(column)s> already exists in table <%(table)s>.") % \
+                                  {'column' : name, 'table' : self.mapDBInfo.layers[self.layer]["table"]},
                               caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
                 return
             index = list.InsertStringItem(sys.maxint, str(name))
@@ -2495,9 +2496,9 @@
         
         if layer in self.mapDBInfo.layers.keys():
             wx.MessageBox(parent=self,
-                          message=_("Unable to add new layer to vector map <%s>.%s"
-                                    "Layer %d already exists.") % \
-                          (self.mapDBInfo.map, os.linesep, layer),
+                          message=_("Unable to add new layer to vector map <%(vector)s>.\n"
+                                    "Layer %(layer)d already exists.") % 
+                          {'vector' : self.mapDBInfo.map, 'layer' : layer},
                           caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
             return
 
@@ -2677,11 +2678,11 @@
 
             wx.MessageBox(parent=self.parent,
                           message=_("No attribute table linked to "
-                                    "vector map <%s> found. %s "
-                                    "%sYou can disable this message from digitization settings. Or "
+                                    "vector map <%(vector)s> found. %(msg)s "
+                                    "\nYou can disable this message from digitization settings. Or "
                                     "you can create and link attribute table to the vector map "
-                                    "using Attribute Table Manager.") % \
-                              (self.map, label, os.linesep),
+                                    "using Attribute Table Manager.") % 
+                          {'vector' : self.map, 'msg' : label},
                           caption=_("Message"), style=wx.OK | wx.ICON_EXCLAMATION | wx.CENTRE)
             self.mapDBInfo = None
             return
@@ -2915,7 +2916,7 @@
                                            size=(-1, 150))
             panel.SetupScrolling(scroll_x=False)
             
-            self.notebook.AddPage(page=panel, text=_(" %s %d ") % (_("Layer"), layer))
+            self.notebook.AddPage(page=panel, text=" %s %d " % (_("Layer"), layer))
             
             # notebook body
             border = wx.BoxSizer(wx.VERTICAL)

Modified: grass/trunk/gui/wxpython/gui_modules/digit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/digit.py	2008-02-26 20:36:32 UTC (rev 30364)
+++ grass/trunk/gui/wxpython/gui_modules/digit.py	2008-02-26 21:20:43 UTC (rev 30365)
@@ -1508,9 +1508,9 @@
         vertexSizer.Add(item=self.snapVertex, proportion=0, flag=wx.EXPAND)
         self.mapUnits = self.parent.MapWindow.Map.ProjInfo()['units']
         self.snappingInfo = wx.StaticText(parent=panel, id=wx.ID_ANY,
-                                          label=_("Snapping threshold is %.1f %s") % \
-                                              (self.parent.digit.driver.GetThreshold(),
-                                               self.mapUnits))
+                                          label=_("Snapping threshold is %(value).1f %(units)s") % \
+                                              {'value' : self.parent.digit.driver.GetThreshold(),
+                                               'units' : self.mapUnits})
         vertexSizer.Add(item=self.snappingInfo, proportion=0,
                         flag=wx.ALL | wx.EXPAND, border=1)
 
@@ -1749,9 +1749,9 @@
         else:
             threshold = self.parent.digit.driver.GetThreshold(value)
 
-        self.snappingInfo.SetLabel(_("Snapping threshold is %.1f %s") % 
-                                   (threshold,
-                                    self.mapUnits))
+        self.snappingInfo.SetLabel(_("Snapping threshold is %(value).1f %(units)s") % 
+                                   {'value' : threshold,
+                                    'units' : self.mapUnits})
 
         event.Skip()
 
@@ -1762,13 +1762,13 @@
         threshold = self.parent.digit.driver.GetThreshold(value, units)
 
         if units == "map units":
-            self.snappingInfo.SetLabel(_("Snapping threshold is %.1f %s") % \
-                                           (value,
-                                            self.mapUnits))
+            self.snappingInfo.SetLabel(_("Snapping threshold is %(value).1f %(name)s") % 
+                                       {'value' : value,
+                                        'units' : self.mapUnits})
         else:
-            self.snappingInfo.SetLabel(_("Snapping threshold is %.1f %s") % \
-                                           (threshold,
-                                            self.mapUnits))
+            self.snappingInfo.SetLabel(_("Snapping threshold is %(value).1f %(units)s") % 
+                                       {'value' : threshold,
+                                        'units' : self.mapUnits})
             
         event.Skip()
 
@@ -2048,10 +2048,11 @@
             event.Veto()
             self.list.SetStringItem(itemIndex, 0, str(layerNew))
             self.list.SetStringItem(itemIndex, 1, str(catNew))
-            dlg = wx.MessageDialog(self, _("Unable to add new layer/category <%s/%s>.\n"
+            dlg = wx.MessageDialog(self, _("Unable to add new layer/category <%(layer)s/%(category)s>.\n"
                                            "Layer and category number must be integer.\n"
                                            "Layer number must be greater then zero.") %
-                                   (str(self.layerNew.GetValue()), str(self.catNew.GetValue())),
+                                   { 'layer': str(self.layerNew.GetValue()),
+                                     'category' : str(self.catNew.GetValue()) },
                                    _("Error"), wx.OK | wx.ICON_ERROR)
             dlg.ShowModal()
             dlg.Destroy()
@@ -2218,10 +2219,11 @@
             if layer <= 0:
                 raise ValueError
         except ValueError:
-            dlg = wx.MessageDialog(self, _("Unable to add new layer/category <%s/%s>.\n"
+            dlg = wx.MessageDialog(self, _("Unable to add new layer/category <%(layer)s/%(category)s>.\n"
                                            "Layer and category number must be integer.\n"
                                            "Layer number must be greater then zero.") %
-                                   (str(self.layerNew.GetValue()), str(self.catNew.GetValue())),
+                                   {'layer' : str(self.layerNew.GetValue()),
+                                    'category' : str(self.catNew.GetValue())},
                                    _("Error"), wx.OK | wx.ICON_ERROR)
             dlg.ShowModal()
             dlg.Destroy()

Modified: grass/trunk/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcmd.py	2008-02-26 20:36:32 UTC (rev 30364)
+++ grass/trunk/gui/wxpython/gui_modules/gcmd.py	2008-02-26 21:20:43 UTC (rev 30365)
@@ -271,11 +271,13 @@
                 if rerr is False: # GUI dialog
                     try:
                         raise CmdError(cmd=self.cmd,
-                                       message=_("Execution failed: '%s'%s%s" 
-                                                 "Details:%s%s") % (' '.join(self.cmd),
-                                                                    os.linesep, os.linesep,
-                                                                    os.linesep,
-                                                                    self.PrintModuleOutput()))
+                                       message="%s '%s'%s%s%s %s%s" %
+                                       (_("Execution failed:"),
+                                        ' '.join(self.cmd),
+                                        os.linesep, os.linesep,
+                                        _("Details:"),
+                                        os.linesep,
+                                        self.PrintModuleOutput()))
                     except CmdError, e:
                         print e
                 elif rerr == sys.stderr: # redirect message to sys

Modified: grass/trunk/gui/wxpython/gui_modules/location_wizard.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/location_wizard.py	2008-02-26 20:36:32 UTC (rev 30364)
+++ grass/trunk/gui/wxpython/gui_modules/location_wizard.py	2008-02-26 21:20:43 UTC (rev 30365)
@@ -208,11 +208,10 @@
             error = _("Location already exists in GRASS Database.")
 
         if error != '':
-            dlg = wx.MessageDialog(parent=self, message=_("Unable to create location <%s>.%s"
-                                                          "%s" % \
-                                                              (str(self.tlocation.GetValue()),
-                                                               os.linesep,
-                                                               error)),
+            dlg = wx.MessageDialog(parent=self, message="%s <%s>.%s%s" % (_("Unable to create location"),
+                                                                          str(self.tlocation.GetValue()),
+                                                                          os.linesep,
+                                                                          error),
                                    caption=_("Error"),  style=wx.OK | wx.ICON_ERROR)
             
             dlg.ShowModal()

Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2008-02-26 20:36:32 UTC (rev 30364)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2008-02-26 21:20:43 UTC (rev 30365)
@@ -69,7 +69,7 @@
 import os
 from os import system
 import gettext
-gettext.install("wxgui")
+gettext.install("grasswx")
 
 gisbase = os.getenv("GISBASE")
 import globalvar
@@ -258,7 +258,8 @@
                     cmd += [ '%s=%s' % ( p['name'], p['default'] ) ]
                 else:
                     cmd += [ '%s=%s' % ( p['name'], _('<required>') ) ]
-                    errStr += _("Parameter %s (%s) is missing.\n") % ( p['name'], p['description'] )
+                    errStr += _("Parameter %(name)s (%(desc)s) is missing.\n") % \
+                        {'name' : p['name'], 'desc' : p['description']}
                     errors += 1
             elif p.get('value','') != '' and p['value'] != p.get('default','') :
                 # Output only values that have been set, and different from defaults
@@ -939,8 +940,8 @@
                 else:
                     if len(valuelist) == 1: # -> textctrl
                         txt = wx.StaticText(parent=which_panel,
-                                            label = _('%s. Valid range=%s') % \
-                                                (title, str(valuelist).strip("[]'") + ':' ) )
+                                            label = "%s. %s=%s" (title, _('Valid range'),
+                                                                 str(valuelist).strip("[]'") + ':'))
                         which_sizer.Add(item=txt, proportion=0,
                                         flag=wx.ADJUST_MINSIZE | wx.TOP | wx.RIGHT | wx.LEFT, border=5)
 

Modified: grass/trunk/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/render.py	2008-02-26 20:36:32 UTC (rev 30364)
+++ grass/trunk/gui/wxpython/gui_modules/render.py	2008-02-26 21:20:43 UTC (rev 30365)
@@ -97,8 +97,8 @@
                       'overlay']
 
         if self.type not in layertypes:
-            raise gcmd.GException(_("Type <%s> of layer <%s> is not supported yet") % \
-                                      (self.type, self.name))
+            raise gcmd.GException(_("Type <%(type)s> of layer <%(name)s> is not supported yet") % \
+                                      {'type' : self.type, 'name' : self.name})
         
         #
         # start monitor
@@ -256,8 +256,7 @@
         try:
             windfile = open (windfile, "r")
         except StandardError, e:
-            sys.stderr.write(_("Unable to open file <%s>: %s") % \
-                                 (windfile,e))
+            sys.stderr.write("%s %<s>: %s" % (_("Unable to open file"), windfile, e))
             sys.exit(1)
 
         for line in windfile.readlines():

Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2008-02-26 20:36:32 UTC (rev 30364)
+++ grass/trunk/gui/wxpython/wxgui.py	2008-02-26 21:20:43 UTC (rev 30365)
@@ -588,8 +588,8 @@
             file.close()
         except IOError, err:
             wx.MessageBox(parent=self,
-                          message=_("Unable to read workspace file <%s>.%s%s") % \
-                          (filename, os.linesep, err),
+                          message="%s <%s>. %s%s" % (_("Unable to read workspace file"),
+                                                     filename, os.linesep, err),
                           caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
             return False
 



More information about the grass-commit mailing list