diff options
Diffstat (limited to 'Lib/xml')
-rw-r--r-- | Lib/xml/dom/domreg.py | 2 | ||||
-rw-r--r-- | Lib/xml/dom/minidom.py | 18 | ||||
-rw-r--r-- | Lib/xml/dom/xmlbuilder.py | 4 | ||||
-rw-r--r-- | Lib/xml/sax/__init__.py | 4 | ||||
-rw-r--r-- | Lib/xml/sax/xmlreader.py | 9 |
5 files changed, 17 insertions, 20 deletions
diff --git a/Lib/xml/dom/domreg.py b/Lib/xml/dom/domreg.py index 684c436..ec3acdf 100644 --- a/Lib/xml/dom/domreg.py +++ b/Lib/xml/dom/domreg.py @@ -57,7 +57,7 @@ def getDOMImplementation(name = None, features = ()): return mod.getDOMImplementation() elif name: return registered[name]() - elif os.environ.has_key("PYTHON_DOM"): + elif "PYTHON_DOM" in os.environ: return getDOMImplementation(name = os.environ["PYTHON_DOM"]) # User did not specify a name, try implementations in arbitrary diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py index 3a35781..1a3b74f 100644 --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -243,7 +243,7 @@ class Node(xml.dom.Node): except AttributeError: d = {} self._user_data = d - if d.has_key(key): + if key in d: old = d[key][0] if data is None: # ignore handlers passed for None @@ -494,11 +494,11 @@ class NamedNodeMap(object): L.append(((node.namespaceURI, node.localName), node.value)) return L - def has_key(self, key): + def __contains__(self, key): if isinstance(key, StringTypes): - return self._attrs.has_key(key) + return key in self._attrs else: - return self._attrsNS.has_key(key) + return key in self._attrsNS def keys(self): return self._attrs.keys() @@ -560,7 +560,7 @@ class NamedNodeMap(object): _clear_id_cache(self._ownerElement) del self._attrs[n.nodeName] del self._attrsNS[(n.namespaceURI, n.localName)] - if n.__dict__.has_key('ownerElement'): + if 'ownerElement' in n.__dict__: n.__dict__['ownerElement'] = None return n else: @@ -572,7 +572,7 @@ class NamedNodeMap(object): _clear_id_cache(self._ownerElement) del self._attrsNS[(n.namespaceURI, n.localName)] del self._attrs[n.nodeName] - if n.__dict__.has_key('ownerElement'): + if 'ownerElement' in n.__dict__: n.__dict__['ownerElement'] = None return n else: @@ -779,10 +779,10 @@ class Element(Node): removeAttributeNodeNS = removeAttributeNode def hasAttribute(self, name): - return self._attrs.has_key(name) + return name in self._attrs def hasAttributeNS(self, namespaceURI, localName): - return self._attrsNS.has_key((namespaceURI, localName)) + return (namespaceURI, localName) in self._attrsNS def getElementsByTagName(self, name): return _get_elements_by_tagName_helper(self, name, NodeList()) @@ -1660,7 +1660,7 @@ class Document(Node, DocumentLS): return n def getElementById(self, id): - if self._id_cache.has_key(id): + if id in self._id_cache: return self._id_cache[id] if not (self._elem_info or self._magic_id_count): return None diff --git a/Lib/xml/dom/xmlbuilder.py b/Lib/xml/dom/xmlbuilder.py index ac1d448..dc7c5d4 100644 --- a/Lib/xml/dom/xmlbuilder.py +++ b/Lib/xml/dom/xmlbuilder.py @@ -91,7 +91,7 @@ class DOMBuilder: def canSetFeature(self, name, state): key = (_name_xform(name), state and 1 or 0) - return self._settings.has_key(key) + return key in self._settings # This dictionary maps from (feature,value) to a list of # (option,value) pairs that should be set on the Options object. @@ -247,7 +247,7 @@ class DOMEntityResolver(object): def _guess_media_encoding(self, source): info = source.byteStream.info() - if info.has_key("Content-Type"): + if "Content-Type" in info: for param in info.getplist(): if param.startswith("charset="): return param.split("=", 1)[1].lower() diff --git a/Lib/xml/sax/__init__.py b/Lib/xml/sax/__init__.py index 054064c..d55ffb7 100644 --- a/Lib/xml/sax/__init__.py +++ b/Lib/xml/sax/__init__.py @@ -59,7 +59,7 @@ if _false: import xml.sax.expatreader import os, sys -if os.environ.has_key("PY_SAX_PARSER"): +if "PY_SAX_PARSER" in os.environ: default_parser_list = os.environ["PY_SAX_PARSER"].split(",") del os @@ -81,7 +81,7 @@ def make_parser(parser_list = []): return _create_parser(parser_name) except ImportError,e: import sys - if sys.modules.has_key(parser_name): + if parser_name in sys.modules: # The parser module was found, but importing it # failed unexpectedly, pass this exception through raise diff --git a/Lib/xml/sax/xmlreader.py b/Lib/xml/sax/xmlreader.py index 1cade65..1763ea4 100644 --- a/Lib/xml/sax/xmlreader.py +++ b/Lib/xml/sax/xmlreader.py @@ -294,12 +294,12 @@ class AttributesImpl: return self._attrs[name] def getNameByQName(self, name): - if not self._attrs.has_key(name): + if name not in self._attrs: raise KeyError, name return name def getQNameByName(self, name): - if not self._attrs.has_key(name): + if name not in self._attrs: raise KeyError, name return name @@ -318,11 +318,8 @@ class AttributesImpl: def keys(self): return self._attrs.keys() - def has_key(self, name): - return self._attrs.has_key(name) - def __contains__(self, name): - return self._attrs.has_key(name) + return name in self._attrs def get(self, name, alternative=None): return self._attrs.get(name, alternative) |