dabo Commit
Revision 5828
Date: 2010-05-19 07:14:37 -0700 (Wed, 19 May 2010)
Author: Ed
Trac: http://trac.dabodev.com/changeset/5828

Changed:
U   trunk/dabo/biz/dAutoBizobj.py
U   trunk/dabo/dApp.py
U   trunk/dabo/dObject.py
U   trunk/dabo/dSecurityManager.py
U   trunk/dabo/db/dCursorMixin.py
U   trunk/dabo/lib/xmltodict.py
U   trunk/dabo/ui/__init__.py
U   trunk/dabo/ui/uiwx/__init__.py
U   trunk/dabo/ui/uiwx/dControlItemMixin.py
U   trunk/dabo/ui/uiwx/dDataControlMixin.py
U   trunk/dabo/ui/uiwx/dDateTextBox.py
U   trunk/dabo/ui/uiwx/dEditor.py
U   trunk/dabo/ui/uiwx/dForm.py
U   trunk/dabo/ui/uiwx/dPemMixin.py
U   trunk/dabo/ui/uiwx/dSlidePanelControl.py
U   trunk/dabo/ui/uiwx/dToggleButton.py

Log:
Changed string substitution to work with localization

Diff:
Modified: trunk/dabo/biz/dAutoBizobj.py
===================================================================
--- trunk/dabo/biz/dAutoBizobj.py       2010-05-19 13:27:07 UTC (rev 5827)
+++ trunk/dabo/biz/dAutoBizobj.py       2010-05-19 14:14:37 UTC (rev 5828)
@@ -64,7 +64,8 @@
   1. using this program by TEMPORARLY giving this program access to the 
database to create the needed tables.
   2. or executing all the quries in the 'queries.sql' file."""))
 
-                                       lblinst2 = 
self.addObject(dabo.ui.dLabel, Caption=_("DBA, please enter the username and 
password that has access to create tables for database on server '%s' and 
database '%s'") % (self._conn.ConnectInfo.Host, 
self._conn.ConnectInfo.Database))
+                                       hst, db = self._conn.ConnectInfo.Host, 
self._conn.ConnectInfo.Database
+                                       lblinst2 = 
self.addObject(dabo.ui.dLabel, Caption=_("DBA, please enter the username and 
password that has access to create tables for database on server '%(hst)s' and 
database '%(db)s'") % locals())
 
                                        o = self.addObject(dabo.ui.dLabel, 
Caption=_("Username"))
                                        cs.append(o, row=0, col=0, border=3)
@@ -161,10 +162,10 @@
 def _writeQueriesToFile(queries):
        f = open("queries.sql", "w")
        for k in queries.keys():
-               f.write(_("#Queries for DB '%s' on host '%s':\n") % 
(k.ConnectInfo.Database, k.ConnectInfo.Host))
+               db, hst = k.ConnectInfo.Database, k.ConnectInfo.Host
+               f.write(_("#Queries for DB '%(db)s' on host '%(hst)s':\n") % 
locals())
                for query in queries[k]:
                        f.write("%s;\n" % (query))
-
        f.close()
 
 

Modified: trunk/dabo/dApp.py
===================================================================
--- trunk/dabo/dApp.py  2010-05-19 13:27:07 UTC (rev 5827)
+++ trunk/dabo/dApp.py  2010-05-19 14:14:37 UTC (rev 5828)
@@ -993,7 +993,7 @@
                try:
                        connDefs = importConnections(filePath, useHomeDir=True)
                except SAXParseException, e:
-                       dabo.errorLog.write(_("Error parsing '%s': %s") % 
(filePath, e))
+                       dabo.errorLog.write(_("Error parsing '%(filePath)s': 
%(e)s") % locals())
                        return {}
                # Convert the connect info dicts to dConnectInfo instances:
                for k,v in connDefs.items():

Modified: trunk/dabo/dObject.py
===================================================================
--- trunk/dabo/dObject.py       2010-05-19 13:27:07 UTC (rev 5827)
+++ trunk/dabo/dObject.py       2010-05-19 14:14:37 UTC (rev 5828)
@@ -250,8 +250,8 @@
                                code = code.replace("\n]", "]")
                                compCode = compile(code, "", "exec")
                        except SyntaxError, e:
-                               dabo.errorLog.write(_("Method '%s' of object 
'%s' has the following error: %s")
-                                               % (nm, self.Name, e))
+                               snm = self.Name
+                               dabo.errorLog.write(_("Method '%(nm)s' of 
object '%(snm)s' has the following error: %(e)s") % locals())
                                continue
                        # OK, we have the compiled code. Add it to the class 
definition.
                        # NOTE: if the method name and the name in the 'def' 
statement

Modified: trunk/dabo/dSecurityManager.py
===================================================================
--- trunk/dabo/dSecurityManager.py      2010-05-19 13:27:07 UTC (rev 5827)
+++ trunk/dabo/dSecurityManager.py      2010-05-19 14:14:37 UTC (rev 5828)
@@ -19,8 +19,8 @@
                message = self.LoginMessage
                for attempt in range(self.LoginAttemptsAllowed):
                        if attempt > 0:
-                               message = _("Login incorrect, please try again. 
(%s/%s)") % (
-                                               attempt+1, 
self.LoginAttemptsAllowed)
+                               num, allwd = attempt+1, 
self.LoginAttemptsAllowed
+                               message = _("Login incorrect, please try again. 
(%(num)s/%(allwd)s)") % locals()
                        loginInfo = self.Application.getLoginInfo(message)
                        
                        if isinstance(loginInfo[1], dict):

Modified: trunk/dabo/db/dCursorMixin.py
===================================================================
--- trunk/dabo/db/dCursorMixin.py       2010-05-19 13:27:07 UTC (rev 5827)
+++ trunk/dabo/db/dCursorMixin.py       2010-05-19 14:14:37 UTC (rev 5828)
@@ -253,8 +253,9 @@
                                try:
                                        return pythonType(field_val)
                                except Exception, e:
-                                       
dabo.infoLog.write(_("_correctFieldType() failed for field: '%s'; value: '%s'; 
type: '%s'") %
-                                                       (field_name, field_val, 
type(field_val)))
+                                       tfv = type(field_val)
+                                       
dabo.infoLog.write(_("_correctFieldType() failed for field: '%(field_name)s'; 
value: '%(field_val)s'; type: '%(tfv)s'")
+                                                       % locals())
 
                # Do the unicode conversion last:
                if isinstance(field_val, str) and self._convertStrToUnicode:
@@ -283,8 +284,9 @@
 #                      # Usually blob data
 #                      ret = field_val.tostring()
 
-                       dabo.errorLog.write(_("%s couldn't be converted to %s 
(field %s)")
-                                       % (repr(field_val), pythonType, 
field_name))
+                       rfv = repr(field_val)
+                       dabo.errorLog.write(_("%(rfv)s couldn't be converted to 
%(pythonType)s (field %(field_name)s)")
+                                       % locals())
                return ret
 
 
@@ -841,8 +843,9 @@
                try:
                        rec = self._records[row]
                except IndexError:
+                       cnt = len(self._records)
                        raise dException.RowNotFoundException(
-                                       _("Row #%s requested, but the data set 
has only %s row(s),") % (row, len(self._records)))
+                                       _("Row #%(row)s requested, but the data 
set has only %(cnt)s row(s),") % locals())
                if isinstance(fld, (tuple, list)):
                        ret = []
                        for xFld in fld:
@@ -928,8 +931,9 @@
                try:
                        rec = self._records[row]
                except IndexError:
+                       cnt = len(self._records)
                        raise dException.RowNotFoundException(
-                                       _("Row #%s requested, but the data set 
has only %s row(s),") % (row, len(self._records)))
+                                       _("Row #%(row)s requested, but the data 
set has only %(cnt)s row(s),") % locals())
                valid_pk = self._hasValidKeyField()
                keyField = self.KeyField
                if fld not in rec:
@@ -991,8 +995,8 @@
                                        ignore = (rec.get(keyField, None) in 
self._newRecords)
 
                                if not ignore:
-                                       msg = _("!!! Data Type Mismatch: 
field=%s. Expecting: %s; got: %s") \
-                                                       % (fld, str(fldType), 
str(type(val)))
+                                       sft, stv = str(fldType), str(type(val))
+                                       msg = _("!!! Data Type Mismatch: 
field=%(fld)s. Expecting: %(sft)s; got: %(stv)s") % locals()
                                        dabo.errorLog.write(msg)
 
                # If the new value is different from the current value, change 
it and also
@@ -1766,7 +1770,8 @@
                                if key == pk:
                                        return (idx, rec)
                if raiseRowNotFound:
-                       raise dException.RowNotFoundException, _("PK '%s' not 
found in table '%s' (RowCount: %s)") % (pk, self.Table, self.RowCount)
+                       tbl, rc = self.Table, self.RowCount
+                       raise dException.RowNotFoundException(_("PK '%(pk)s' 
not found in table '%(tbl)s' (RowCount: %(rc)s)") % locals())
                return (None, None)
 
 
@@ -1800,7 +1805,8 @@
                and an exception is raised.
                """
                if (rownum >= self.RowCount) or (rownum < 0):
-                       raise dException.dException(_("Invalid row specified: 
%s. RowCount=%s") % (rownum, self.RowCount))
+                       rc = self.RowCount
+                       raise dException.dException(_("Invalid row specified: 
%(rownum)s. RowCount=%(rc)s") % locals())
                self.RowNumber = rownum
 
 

Modified: trunk/dabo/lib/xmltodict.py
===================================================================
--- trunk/dabo/lib/xmltodict.py 2010-05-19 13:27:07 UTC (rev 5827)
+++ trunk/dabo/lib/xmltodict.py 2010-05-19 14:14:37 UTC (rev 5828)
@@ -197,7 +197,7 @@
                try:
                        ret = parser.Parse(xmlContent)
                except expat.ExpatError, e:
-                       errmsg = _("The XML in '%s' is not well-formed and 
cannot be parsed: %s") % (xml, e)
+                       errmsg = _("The XML in '%(xml)s' is not well-formed and 
cannot be parsed: %(e)s") % locals()
        else:
                # argument must have been raw xml:
                try:

Modified: trunk/dabo/ui/__init__.py
===================================================================
--- trunk/dabo/ui/__init__.py   2010-05-19 13:27:07 UTC (rev 5827)
+++ trunk/dabo/ui/__init__.py   2010-05-19 14:14:37 UTC (rev 5828)
@@ -67,8 +67,8 @@
                        # No problem; just a redundant call
                        pass
                else:
-                       dabo.infoLog.write(_("Cannot change the uiType to '%s', 
because UI '%s' is already loaded.")
-                               % (typ, currType))
+                       dabo.infoLog.write(_("Cannot change the uiType to 
'%(typ)s', because UI '%(currType)s' is already loaded.")
+                                       % locals())
        return retVal
 
        
@@ -137,13 +137,13 @@
                else:
                        self._dynamic[propName] = func
 
-       doc = _("""Dynamically determine the value of the %s property.
+       doc = _("""Dynamically determine the value of the %(propName)s property.
 
 Specify a function and optional arguments that will get called from the
 update() method. The return value of the function will get set to the
-%s property. If Dynamic%s is set to None (the default), %s 
+%(propName)s property. If Dynamic%(propName)s is set to None (the default), 
%(propName)s 
 will not be dynamically evaluated.
-""") % (propName, propName, propName, propName)
+""") % locals()
 
        if additionalDoc:
                doc += "\n\n" + additionalDoc

Modified: trunk/dabo/ui/uiwx/__init__.py
===================================================================
--- trunk/dabo/ui/uiwx/__init__.py      2010-05-19 13:27:07 UTC (rev 5827)
+++ trunk/dabo/ui/uiwx/__init__.py      2010-05-19 14:14:37 UTC (rev 5828)
@@ -288,8 +288,8 @@
                fnc = eval("obj.__class__.%s.fset" % prop)
                wx.CallAfter(fnc, obj, val)
        except StandardError, e:
-               dabo.errorLog.write(_("setAfter() failed to set property '%s' 
to value '%s': %s.")
-                               % (prop, val, e))
+               dabo.errorLog.write(_("setAfter() failed to set property 
'%(prop)s' to value '%(val)s': %(e)s.")
+                               % locals())
 
 
 def setAfterInterval(interval, obj, prop, val):
@@ -300,8 +300,8 @@
                fnc = eval("obj.__class__.%s.fset" % prop)
                callAfterInterval(interval, fnc, obj, val)
        except StandardError, e:
-               dabo.errorLog.write(_("setAfterInterval() failed to set 
property '%s' to value '%s': %s.")
-                               % (prop, val, e))
+               dabo.errorLog.write(_("setAfterInterval() failed to set 
property '%(prop)s' to value '%(val)s': %(e)s.")
+                               % locals())
 
 
 def callEvery(interval, func, *args, **kwargs):

Modified: trunk/dabo/ui/uiwx/dControlItemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dControlItemMixin.py     2010-05-19 13:27:07 UTC (rev 
5827)
+++ trunk/dabo/ui/uiwx/dControlItemMixin.py     2010-05-19 14:14:37 UTC (rev 
5828)
@@ -236,7 +236,8 @@
                                invalidSelections = []
 
                        if invalidSelections:
-                               raise ValueError(_("Trying to set %s.Value to 
these invalid selections: %s") % (self.Name, invalidSelections))
+                               snm = self.Name
+                               raise ValueError(_("Trying to set %(snm)s.Value 
to these invalid selections: %(invalidSelections)s") % locals())
 
                        self._afterValueChanged()
                else:

Modified: trunk/dabo/ui/uiwx/dDataControlMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dDataControlMixin.py     2010-05-19 13:27:07 UTC (rev 
5827)
+++ trunk/dabo/ui/uiwx/dDataControlMixin.py     2010-05-19 14:14:37 UTC (rev 
5828)
@@ -83,8 +83,9 @@
                                try:
                                        setter(val)
                                except (TypeError, ValueError), e:
-                                       dabo.errorLog.write(_("Could not set 
value of %s to %s. Error message: %s")
-                                                       % (self._name, val, e))
+                                       nm = self._name
+                                       dabo.errorLog.write(_("Could not set 
value of %(nm)s to %(val)s. Error message: %(e)s")
+                                                       % locals())
                        self.flushValue()
                else:
                        self._properties["Value"] = val

Modified: trunk/dabo/ui/uiwx/dDateTextBox.py
===================================================================
--- trunk/dabo/ui/uiwx/dDateTextBox.py  2010-05-19 13:27:07 UTC (rev 5827)
+++ trunk/dabo/ui/uiwx/dDateTextBox.py  2010-05-19 14:14:37 UTC (rev 5828)
@@ -231,7 +231,8 @@
                                # Probably just a null value
                                orig = None
                        else:
-                               dabo.errorLog.write(_("Non-date value in %s: 
'%s' is type '%s'") % (self.Name, val, type(val)))
+                               nm, tv = self.Name, type(val)
+                               dabo.errorLog.write(_("Non-date value in 
%(nm)s: '%(val)s' is type '%(tv)s'") % locals())
                                return
                # Default direction
                forward = True

Modified: trunk/dabo/ui/uiwx/dEditor.py
===================================================================
--- trunk/dabo/ui/uiwx/dEditor.py       2010-05-19 13:27:07 UTC (rev 5827)
+++ trunk/dabo/ui/uiwx/dEditor.py       2010-05-19 14:14:37 UTC (rev 5828)
@@ -225,7 +225,8 @@
                # printing
                if not self.IsPreview():
                        if ep < stcEndPos:
-                               print _('warning: on page %s: not enough chars 
rendered, diff: %s')%(page, stcEndPos-ep)
+                               posdiff = stcEndPos-ep
+                               dabo.errorLog.write(_('warning: on page 
%(page)s: not enough chars rendered, diff: %(posdiff)s') % locals())
                return True
 
 
@@ -2412,8 +2413,9 @@
                                try:
                                        self.Text = val
                                except TypeError, e:
-                                       dabo.errorLog.write(_("Could not set 
value of %s to %s. Error message: %s")
-                                                       % (self._name, val, e))
+                                       nm = self._name
+                                       dabo.errorLog.write(_("Could not set 
value of %(nm)s to %(val)s. Error message: %(e)s")
+                                                       % locals())
                                self._afterValueChanged()
                        self.flushValue()
                else:

Modified: trunk/dabo/ui/uiwx/dForm.py
===================================================================
--- trunk/dabo/ui/uiwx/dForm.py 2010-05-19 13:27:07 UTC (rev 5827)
+++ trunk/dabo/ui/uiwx/dForm.py 2010-05-19 14:14:37 UTC (rev 5828)
@@ -496,16 +496,13 @@
                                                newRowNumber=newRowNumber, 
oldRowNumber=oldRowNumber,
                                                bizobj=bizobj)
 
-
                        # We made it through without errors
                        ret = True
-               
+                       rc = bizobj.RowCount
+                       plcnt = bizobj.RowCount == 1 and " " or "s "
+                       plelap = elapsed == 1 and "." or "s."
                        self.StatusText = (
-                                       _("%s record%sselected in %s second%s") 
% (
-                                       bizobj.RowCount, 
-                                       bizobj.RowCount == 1 and " " or "s ",
-                                       elapsed,
-                                       elapsed == 1 and "." or "s."))
+                                       _("%(rc)s record%(plcnt)sselected in 
%(elapsed)s second%(plelap)s") % locals())
 
                except dException.MissingPKException, e:
                        self.notifyUser(str(e), title=_("Requery Failed"), 
severe=True, exception=e)
@@ -773,7 +770,7 @@
                                        rowNumber = 1
                if rowCount < 1:
                        return _("No records")
-               return _("Record %s/%s") % (rowNumber, rowCount)
+               return _("Record %(rowNumber)s/%(rowCount)s") % locals()
 
 
        def validateField(self, ctrl):
@@ -815,7 +812,7 @@
                override it with your own code to handle this failure 
                appropriately for your application.
                """
-               self.StatusText = _(u"Validation failed for %s: %s") % (df, err)
+               self.StatusText = _(u"Validation failed for %(df)s: %(err)s") % 
locals()
                dabo.ui.callAfter(ctrl.setFocus)
                
        

Modified: trunk/dabo/ui/uiwx/dPemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dPemMixin.py     2010-05-19 13:27:07 UTC (rev 5827)
+++ trunk/dabo/ui/uiwx/dPemMixin.py     2010-05-19 14:14:37 UTC (rev 5828)
@@ -454,12 +454,13 @@
                        if not mthdString:
                                # Empty method string; this is a sign of a bug 
in the UI code.
                                # Log it and continue
-                               dabo.errorLog.write(_("Empty Event Binding: 
Object: %s; Event: %s") % (self.Name, evt))
+                               nm = self.Name
+                               dabo.errorLog.write(_("Empty Event Binding: 
Object: %(nm)s; Event: %(evt)s") % locals())
                                continue
                        try:
                                mthd = eval(mthdString)
                        except (AttributeError, NameError), e:
-                               dabo.errorLog.write(_("Could not evaluate 
method '%s': %s") % (mthdString, e))
+                               dabo.errorLog.write(_("Could not evaluate 
method '%(mthdString)s': %(e)s") % locals())
                                continue
                        self.bindEvent(evt, mthd)
 
@@ -2400,7 +2401,7 @@
                try:
                        self.Form.registerObject(self)
                except KeyError:
-                       err = _("Attempt in object '%s' to set duplicate RegID: 
'%s'") % (self, val)
+                       err = _("Attempt in object '%(self)s' to set duplicate 
RegID: '%(val)s'") % locals()
                        dabo.errorLog.write(err)
                        raise KeyError(err)
                        

Modified: trunk/dabo/ui/uiwx/dSlidePanelControl.py
===================================================================
--- trunk/dabo/ui/uiwx/dSlidePanelControl.py    2010-05-19 13:27:07 UTC (rev 
5827)
+++ trunk/dabo/ui/uiwx/dSlidePanelControl.py    2010-05-19 14:14:37 UTC (rev 
5828)
@@ -176,8 +176,9 @@
 
        def _setBarStyle(self, val):
                if val.lower().strip() not in self._barStylesLow:
-                       dabo.errorLog.write(_("Unknown BarStyle passed: %s. 
BarStyle must be one of: %s")
-                                       % (val, ", ".join(self._barStyles)))
+                       bs = ", ".join(self._barStyles)
+                       dabo.errorLog.write(_("Unknown BarStyle passed: 
%(val)s. BarStyle must be one of: %(bs)s")
+                                       % locals())
                else:
                        self._barStyle = val
                        # Apply it

Modified: trunk/dabo/ui/uiwx/dToggleButton.py
===================================================================
--- trunk/dabo/ui/uiwx/dToggleButton.py 2010-05-19 13:27:07 UTC (rev 5827)
+++ trunk/dabo/ui/uiwx/dToggleButton.py 2010-05-19 14:14:37 UTC (rev 5828)
@@ -111,10 +111,11 @@
 
        def onHit(self, evt):
                if self.Value:
-                       state = ("down", "True")
+                       state = "down"
                else:
-                       state = ("up", "False")
-               self.Caption = _("State: %s (Boolean: %s)") % state
+                       state = "up"
+               bval = self.Value
+               self.Caption = _("State: %(state)s (Boolean: %(bval)s)") % 
locals()
 
 
 if __name__ == "__main__":



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to