dabo Commit
Revision 6057
Date: 2010-10-02 22:01:05 -0700 (Sat, 02 Oct 2010)
Author: Ed
Trac: http://trac.dabodev.com/changeset/6057

Changed:
U   trunk/dabo/lib/reportWriter.py
U   trunk/dabo/lib/xmltodict.py
U   trunk/dabo/ui/__init__.py
U   trunk/dabo/ui/dPemMixinBase.py
U   trunk/dabo/ui/uiwx/dForm.py
U   trunk/dabo/ui/uiwx/dFormMixin.py
U   trunk/dabo/ui/uiwx/dGrid.py
U   trunk/dabo/ui/uiwx/dMenu.py
U   trunk/dabo/ui/uiwx/test.py

Log:
Converted the remaining framework scripts to remove has_key usage.


Diff:
Modified: trunk/dabo/lib/reportWriter.py
===================================================================
--- trunk/dabo/lib/reportWriter.py      2010-10-03 02:15:23 UTC (rev 6056)
+++ trunk/dabo/lib/reportWriter.py      2010-10-03 05:01:05 UTC (rev 6057)
@@ -158,11 +158,11 @@
                        pass
 
                # 2) Try mapping to a variable (self.ord_amount -> 
self.Variables["ord_amount"])
-               if self.Variables.has_key(att):
+               if att in self.Variables:
                        return self.Variables.get(att)
 
                # 3) Try mapping to a field in the dataset (self.ordid -> 
self.Record["ordid"])
-               if self.Record.has_key(att):
+               if att in self.Record:
                        return self.Record.get(att)
 
                raise AttributeError("Can't get attribute '%s'." % att)
@@ -220,7 +220,7 @@
                set up to have the passed prop.
                """
                def getDefault():
-                       if self.AvailableProps.has_key(prop):
+                       if prop in self.AvailableProps:
                                val = self.AvailableProps[prop]["default"]
                                if not evaluate:
                                        # defaults are not stringified:
@@ -229,7 +229,7 @@
                        else:
                                raise ValueError("Property name '%s' 
unrecognized." % prop)
 
-               if self.has_key(prop):
+               if prop in self.AvailableProps:
                        if not evaluate or prop == "type":
                                return self[prop]
                        try:
@@ -246,7 +246,7 @@
 
        def setProp(self, prop, val, logUndo=True):
                """Update the value of the property."""
-               if not self.AvailableProps.has_key(prop):
+               if prop not in self.AvailableProps:
                        raise ValueError("Property '%s' doesn't exist." % prop)
                if logUndo:
                        self.Report.reportWriter.storeUndo(self, prop, 
self.getProp(prop, evaluate=False), val)
@@ -526,9 +526,9 @@
 
 
        def insertRequiredElements(self):
-               if not self.has_key("GroupHeader"):
+               if "GroupHeader" not in self:
                        self["GroupHeader"] = GroupHeader(self)
-               if not self.has_key("GroupFooter"):
+               if "GroupFooter" not in self:
                        self["GroupFooter"] = GroupFooter(parent=self)
 
 
@@ -1581,25 +1581,25 @@
                                expr = unicode(expr)
                        s = copy.deepcopy(s)
 
-                       if fobject.has_key("fontSize"):
+                       if "fontSize" in fobject:
                                s.fontSize = fobject.getProp("fontSize")
 
-                       if fobject.has_key("fontName"):
+                       if "fontName" in fobject:
                                s.fontName = fobject.getProp("fontName")
 
-                       if fobject.has_key("leading"):
+                       if "leading" in fobject:
                                s.leading = fobject.getProp("leading")
 
-                       if fobject.has_key("spaceAfter"):
+                       if "spaceAfter" in fobject:
                                s.spaceAfter = fobject.getProp("spaceAfter")
 
-                       if fobject.has_key("spaceBefore"):
+                       if "spaceBefore" in fobject:
                                s.spaceBefore = fobject.getProp("spaceBefore")
 
-                       if fobject.has_key("leftIndent"):
+                       if "leftIndent" in fobject:
                                s.leftIndent = fobject.getProp("leftIndent")
 
-                       if fobject.has_key("firstLineIndent"):
+                       if "firstLineIndent" in fobject:
                                s.firstLineIndent = 
fobject.getProp("firstLineIndent")
 
                        if t.lower() == "paragraph":
@@ -2335,7 +2335,7 @@
                                        obj = {"name": 
formobj.__class__.__name__, "children": []}
                                        props = formobj.keys()
                                        props.sort(self._elementSort)
-                                       if formobj.has_key(element):
+                                       if element in formobj:
                                                # Recurse
                                                
self._getXMLDictFromForm(formobj, obj)
                                        else:
@@ -2401,7 +2401,7 @@
                if formdict is None:
                        formdict = Report(None)
 
-               if xmldict.has_key("children"):
+               if "children" in xmldict:
                        # children with name of "objects", "variables" or 
"groups" are band
                        # object lists, while other children are 
sub-dictionaries.
                        for child in xmldict["children"]:
@@ -2410,14 +2410,14 @@
                                        # to ignore those if present, and make 
report["TestCursor"] a list of
                                        # records.
                                        cursor = formdict.addElement(TestCursor)
-                                       if child.has_key("children"):
+                                       if "children" in child:
                                                for childrecord in 
child["children"]:
                                                        
cursor.addRecord(childrecord["attributes"])
-                               elif child.has_key("cdata"):
+                               elif "cdata" in child:
                                        formdict[child["name"]] = child["cdata"]
-                               elif child.has_key("attributes"):
+                               elif "attributes" in child:
                                        formdict[child["name"]] = 
child["attributes"]
-                               elif child.has_key("children"):
+                               elif "children" in child:
                                        if child["name"].lower() in ("objects", 
"groups", "variables"):
                                                coll = child["name"]
                                                formdict[coll] = 
self._getReportObject(coll, formdict)

Modified: trunk/dabo/lib/xmltodict.py
===================================================================
--- trunk/dabo/lib/xmltodict.py 2010-10-03 02:15:23 UTC (rev 6056)
+++ trunk/dabo/lib/xmltodict.py 2010-10-03 05:01:05 UTC (rev 6057)
@@ -60,7 +60,7 @@
                        # This is code for the parent element
                        self._inCode = True
                        parent = self.nodeStack[-1]
-                       if not parent.has_key("code"):
+                       if "code" not in parent:
                                parent["code"] = {}
                                self._codeDict = parent["code"]
 
@@ -70,7 +70,7 @@
                        self._propName = ""
                        self._propData = ""
                        parent = self.nodeStack[-1]
-                       if not parent.has_key("properties"):
+                       if "properties" not in parent:
                                parent["properties"] = {}
                                self._propDict = parent["properties"]
 
@@ -101,7 +101,7 @@
                                # Push element onto the stack and make it a 
child of parent
                                if len(self.nodeStack) > 0:
                                        parent = self.nodeStack[-1]
-                                       if not parent.has_key("children"):
+                                       if "children" not in parent:
                                                parent["children"] = []
                                        parent["children"].append(element)
                                else:
@@ -153,7 +153,7 @@
                                self._propData += data
                        else:
                                element = self.nodeStack[-1]
-                               if not element.has_key("cdata"):
+                               if "cdata" not in element:
                                        element["cdata"] = ""
                                element["cdata"] += data
 
@@ -276,7 +276,7 @@
        att = ""
        ret = ""
 
-       if dct.has_key("attributes"):
+       if "attributes" in dct:
                for key, val in dct["attributes"].items():
                        # Some keys are already handled.
                        noEscape = key in ("sizerInfo",)
@@ -284,15 +284,15 @@
                        att += " %s=%s" % (key, val)
        ret += "%s<%s%s" % ("\t" * level, dct["name"], att)
 
-       if (not dct.has_key("cdata") and not dct.has_key("children")
-                       and not dct.has_key("code") and not 
dct.has_key("properties")):
+       if (("cdata" not in dct) and ("children" not in dct) and ("code" not in 
dct)
+                       and ("properties" not in dct)):
                ret += " />%s" % eol
        else:
                ret += ">"
-               if dct.has_key("cdata"):
+               if "cdata" in dct:
                        ret += "%s" % dct["cdata"].replace("<", 
"&lt;").replace(">", "&gt;")
 
-               if dct.has_key("code"):
+               if "code" in dct:
                        if len(dct["code"].keys()):
                                ret += "%s%s<code>%s" % (eol, "\t" * (level+1), 
eol)
                                methodTab = "\t" * (level+2)
@@ -308,7 +308,7 @@
                                                        methodTab, mthd, eol)
                                ret += "%s</code>%s"    % ("\t" * (level+1), 
eol)
 
-               if dct.has_key("properties"):
+               if "properties" in dct:
                        if len(dct["properties"].keys()):
                                ret += "%s%s<properties>%s" % (eol, "\t" * 
(level+1), eol)
                                currTab = "\t" * (level+2)
@@ -321,7 +321,7 @@
                                        ret += "%s</%s>%s" % (currTab, prop, 
eol)
                                ret += "%s</properties>%s"      % ("\t" * 
(level+1), eol)
 
-               if dct.has_key("children") and len(dct["children"]) > 0:
+               if ("children" in dct) and dct["children"]:
                        ret += eol
                        for child in dct["children"]:
                                ret += dicttoxml(child, level+1, 
linesep=linesep)

Modified: trunk/dabo/ui/__init__.py
===================================================================
--- trunk/dabo/ui/__init__.py   2010-10-03 02:15:23 UTC (rev 6056)
+++ trunk/dabo/ui/__init__.py   2010-10-03 05:01:05 UTC (rev 6057)
@@ -132,7 +132,7 @@
                if func is None:
                        # For safety and housekeeping, delete the dynamic prop 
completely,
                        # instead of just setting to None.
-                       if self._dynamic.has_key(propName):
+                       if propName in self._dynamic:
                                del self._dynamic[propName]
                else:
                        self._dynamic[propName] = func

Modified: trunk/dabo/ui/dPemMixinBase.py
===================================================================
--- trunk/dabo/ui/dPemMixinBase.py      2010-10-03 02:15:23 UTC (rev 6056)
+++ trunk/dabo/ui/dPemMixinBase.py      2010-10-03 05:01:05 UTC (rev 6057)
@@ -75,7 +75,7 @@
                else:
                        name = defaultName
 
-               if kwargs.has_key("_explicitName"):
+               if "_explicitName" in kwargs:
                        del(kwargs["_explicitName"])
                return name, _explicitName
 

Modified: trunk/dabo/ui/uiwx/dForm.py
===================================================================
--- trunk/dabo/ui/uiwx/dForm.py 2010-10-03 02:15:23 UTC (rev 6056)
+++ trunk/dabo/ui/uiwx/dForm.py 2010-10-03 05:01:05 UTC (rev 6057)
@@ -660,7 +660,7 @@
                if not parentBizobj and not dataSource:
                        return self.PrimaryBizobj
 
-               if not parentBizobj and self.bizobjs.has_key(dataSource):
+               if not parentBizobj and dataSource in self.bizobjs:
                        return self.bizobjs[dataSource]
 
                if isinstance(dataSource, dabo.biz.dBizobj):
@@ -838,7 +838,7 @@
                if isinstance(self._primaryBizobj, dabo.biz.dBizobj):
                        bo = self._primaryBizobj
                else:
-                       if self.bizobjs.has_key(self._primaryBizobj):
+                       if self._primaryBizobj in self.bizobjs:
                                bo = self.bizobjs[self._primaryBizobj]
                                # Update to bizobj reference
                                self._primaryBizobj = bo

Modified: trunk/dabo/ui/uiwx/dFormMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dFormMixin.py    2010-10-03 02:15:23 UTC (rev 6056)
+++ trunk/dabo/ui/uiwx/dFormMixin.py    2010-10-03 05:01:05 UTC (rev 6057)
@@ -580,13 +580,13 @@
                """
                if hasattr(obj, "RegID"):
                        id = obj.RegID
-                       if self._objectRegistry.has_key(id):
+                       if id in self._objectRegistry:
                                if not isinstance(self._objectRegistry[id], 
dabo.ui.deadObject):
                                        raise KeyError(_("Duplicate RegID '%s' 
found") % id)
                                else:
                                        del self.__dict__[id]
                        self._objectRegistry[id] = obj
-                       if hasattr(self, id) or self.__dict__.has_key(id):
+                       if hasattr(self, id) or id in self.__dict__:
                                dabo.log.error(_("RegID '%s' conflicts with 
existing name") % id)
                        else:
                                self.__dict__[id] = obj
@@ -596,7 +596,7 @@
                """Given a RegID value, this will return a reference to the
                associated object, if any. If not, returns None.
                """
-               if self._objectRegistry.has_key(id):
+               if id in self._objectRegistry:
                        return self._objectRegistry[id]
                else:
                        return None

Modified: trunk/dabo/ui/uiwx/dGrid.py
===================================================================
--- trunk/dabo/ui/uiwx/dGrid.py 2010-10-03 02:15:23 UTC (rev 6056)
+++ trunk/dabo/ui/uiwx/dGrid.py 2010-10-03 05:01:05 UTC (rev 6057)
@@ -2254,7 +2254,7 @@
                                firstRec = {}
                                for field in structure:
                                        firstRec[field[0]] = None
-                                       if not colTypes.has_key(field[0]):
+                                       if field[0] not in colTypes:
                                                colTypes[field[0]] = field[1]
                else:
                        # not a bizobj datasource
@@ -2301,11 +2301,11 @@
                                dt = col.DataType = str
 
                        # See if any order was specified
-                       if colOrder.has_key(colKey):
+                       if colKey in colOrder:
                                col.Order = colOrder[colKey]
 
                        # See if any width was specified
-                       if colWidths.has_key(colKey):
+                       if colKey in colWidths:
                                col.Width = colWidths[colKey]
                        else:
                                # Use a default width

Modified: trunk/dabo/ui/uiwx/dMenu.py
===================================================================
--- trunk/dabo/ui/uiwx/dMenu.py 2010-10-03 02:15:23 UTC (rev 6056)
+++ trunk/dabo/ui/uiwx/dMenu.py 2010-10-03 05:01:05 UTC (rev 6057)
@@ -272,8 +272,10 @@
                        return
                item = self._resolveItem(capIdxOrItem)
                id_ = item.GetId()
-               if self._daboChildren.has_key(id_):
+               try:
                        del self._daboChildren[id_]
+               except KeyError:
+                       pass
 
                if wx.VERSION >= (2,7):
                        # Needed to keep dPemMixin mixed-in in wxPython 2.8

Modified: trunk/dabo/ui/uiwx/test.py
===================================================================
--- trunk/dabo/ui/uiwx/test.py  2010-10-03 02:15:23 UTC (rev 6056)
+++ trunk/dabo/ui/uiwx/test.py  2010-10-03 05:01:05 UTC (rev 6057)
@@ -103,7 +103,7 @@
                                print "ImportError:", e
                                continue
                        objname = "_%s_test" % modname
-                       if mod.__dict__.has_key(objname):
+                       if objname in mod.__dict__:
                                print "Trying to instantiate %s..." % objname
                                try:
                                        obj = mod.__dict__[objname](panel)



_______________________________________________
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