clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Thu, 17 Aug 2017 14:27:06 +0300
changeset 1763 bcc07ff2362c
parent 1762 fcc406143e5b
child 1764 d5df428640ff
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
IDEFrame.py
PLCControler.py
PLCGenerator.py
ProjectController.py
editors/TextViewer.py
editors/Viewer.py
plcopen/plcopen.py
svgui/pyjs/build.py
svgui/pyjs/jsonrpc/django/jsonrpc.py
svgui/pyjs/lib/pyjslib.py
svgui/pyjs/pyjs.py
svgui/svgui_server.py
xmlclass/xmlclass.py
xmlclass/xsdschema.py
--- a/IDEFrame.py	Thu Aug 17 11:39:10 2017 +0300
+++ b/IDEFrame.py	Thu Aug 17 14:27:06 2017 +0300
@@ -786,7 +786,7 @@
                     tab_size = child.GetSize()
                     for page_idx in xrange(child.GetPageCount()):
                         page = child.GetWindowFromIdx(page_idx)
-                        if not tab.has_key("size"):
+                        if not "size" in tab:
                             tab["size"] = (tab_size[0], tab_size[1] + page.GetSize()[1])
                         tab_infos = self.GetTabInfos(page)
                         if tab_infos is not None:
@@ -822,7 +822,7 @@
                 return
             raise ValueError, "Not supported"
 
-        if tabs.has_key("split"):
+        if "split" in tabs:
             self.LoadTabLayout(notebook, tabs["others"])
 
             split_dir, split_ratio = tabs["split"]
@@ -1514,12 +1514,12 @@
                 self.TreeImageDict[self.Controler.GetPouBodyType(infos["name"])])
             if item_alone:
                 self.ProjectTree.SetItemExtraImage(root, self.Controler.GetPouType(infos["name"]))
-        elif infos.has_key("icon") and infos["icon"] is not None:
+        elif "icon" in infos and infos["icon"] is not None:
             icon_name = infos["icon"]
-            if not self.TreeImageDict.has_key(icon_name):
+            if not icon_name in self.TreeImageDict:
                 self.TreeImageDict[icon_name] = self.TreeImageList.Add(GetBitmap(icon_name))
             self.ProjectTree.SetItemImage(root, self.TreeImageDict[icon_name])
-        elif self.TreeImageDict.has_key(infos["type"]):
+        elif infos["type"] in self.TreeImageDict:
             self.ProjectTree.SetItemImage(root, self.TreeImageDict[infos["type"]])
 
         item, root_cookie = self.ProjectTree.GetFirstChild(root)
--- a/PLCControler.py	Thu Aug 17 11:39:10 2017 +0300
+++ b/PLCControler.py	Thu Aug 17 14:27:06 2017 +0300
@@ -1781,7 +1781,7 @@
 
     # Return Base Type of given possible derived type
     def GetBaseType(self, typename, debug=False):
-        if TypeHierarchy.has_key(typename):
+        if typename in TypeHierarchy:
             return typename
 
         datatype = self.GetDataType(typename, debug)
@@ -2412,7 +2412,7 @@
                     exclude[stepname] = True
                     instance.setname(stepname)
                 localid = instance.getlocalId()
-                if not used_id.has_key(localid):
+                if not localid in used_id:
                     new_id[localid] = True
 
             idx = 1
@@ -2421,8 +2421,8 @@
             for instance in instances:
                 localId = instance.getlocalId()
                 bbox.union(instance.getBoundingBox())
-                if used_id.has_key(localId):
-                    while used_id.has_key(idx) or new_id.has_key(idx):
+                if localId in used_id:
+                    while (idx in used_id) or (idx in new_id):
                         idx += 1
                     new_id[idx] = True
                     instance.setlocalId(idx)
--- a/PLCGenerator.py	Thu Aug 17 11:39:10 2017 +0300
+++ b/PLCGenerator.py	Thu Aug 17 14:27:06 2017 +0300
@@ -248,7 +248,7 @@
             pou = self.Project.getpou(pou_name)
             pou_type = pou.getpouType()
             # Verify that POU type exists
-            if pouTypeNames.has_key(pou_type):
+            if pou_type in pouTypeNames:
                 # Create a POU program generator
                 pou_program = PouProgramGenerator(self, pou.getname(), pouTypeNames[pou_type], self.Errors, self.Warnings)
                 program = pou_program.GenerateProgram(pou)
@@ -745,7 +745,7 @@
                         if isinstance(instance, (OutVariableClass, InOutVariableClass)):
                             self.ConnectionTypes[instance.connectionPointIn] = var_type
                             connected = self.GetConnectedConnector(instance.connectionPointIn, body)
-                            if connected is not None and not self.ConnectionTypes.has_key(connected):
+                            if connected is not None and not connected in self.ConnectionTypes:
                                 for related in self.ExtractRelatedConnections(connected):
                                     self.ConnectionTypes[related] = var_type
                 elif isinstance(instance, (ContactClass, CoilClass)):
@@ -754,7 +754,7 @@
                     self.ConnectionTypes[instance.connectionPointIn] = "BOOL"
                     for link in instance.connectionPointIn.getconnections():
                         connected = self.GetLinkedConnector(link, body)
-                        if connected is not None and not self.ConnectionTypes.has_key(connected):
+                        if connected is not None and not connected in self.ConnectionTypes:
                             for related in self.ExtractRelatedConnections(connected):
                                 self.ConnectionTypes[related] = "BOOL"
                 elif isinstance(instance, LeftPowerRailClass):
@@ -766,7 +766,7 @@
                         self.ConnectionTypes[connection] = "BOOL"
                         for link in connection.getconnections():
                             connected = self.GetLinkedConnector(link, body)
-                            if connected is not None and not self.ConnectionTypes.has_key(connected):
+                            if connected is not None and not connected in self.ConnectionTypes:
                                 for related in self.ExtractRelatedConnections(connected):
                                     self.ConnectionTypes[related] = "BOOL"
                 elif isinstance(instance, TransitionClass):
@@ -778,7 +778,7 @@
                             raise PLCGenException, _("SFC transition in POU \"%s\" must be connected.") % self.Name
                         for link in connections:
                             connected = self.GetLinkedConnector(link, body)
-                            if connected is not None and not self.ConnectionTypes.has_key(connected):
+                            if connected is not None and not connected in self.ConnectionTypes:
                                 for related in self.ExtractRelatedConnections(connected):
                                     self.ConnectionTypes[related] = "BOOL"
                 elif isinstance(instance, ContinuationClass):
@@ -798,7 +798,7 @@
                             undefined.append(connected)
                         related = []
                         for connection in undefined:
-                            if self.ConnectionTypes.has_key(connection):
+                            if connection in self.ConnectionTypes:
                                 var_type = self.ConnectionTypes[connection]
                             else:
                                 related.extend(self.ExtractRelatedConnections(connection))
@@ -853,10 +853,10 @@
                 for oname, otype, oqualifier in block_infos["outputs"]:
                     if output_name == oname:
                         if otype.startswith("ANY"):
-                            if not undefined.has_key(otype):
+                            if not otype in undefined:
                                 undefined[otype] = []
                             undefined[otype].append(variable.connectionPointOut)
-                        elif not self.ConnectionTypes.has_key(variable.connectionPointOut):
+                        elif not variable.connectionPointOut in self.ConnectionTypes:
                             for connection in self.ExtractRelatedConnections(variable.connectionPointOut):
                                 self.ConnectionTypes[connection] = otype
         for variable in instance.inputVariables.getvariable():
@@ -869,14 +869,14 @@
                     if input_name == iname:
                         connected = self.GetConnectedConnector(variable.connectionPointIn, body)
                         if itype.startswith("ANY"):
-                            if not undefined.has_key(itype):
+                            if not itype in undefined:
                                 undefined[itype] = []
                             undefined[itype].append(variable.connectionPointIn)
                             if connected is not None:
                                 undefined[itype].append(connected)
                         else:
                             self.ConnectionTypes[variable.connectionPointIn] = itype
-                            if connected is not None and not self.ConnectionTypes.has_key(connected):
+                            if connected is not None and not connected in self.ConnectionTypes:
                                 for connection in self.ExtractRelatedConnections(connected):
                                     self.ConnectionTypes[connection] = itype
         for var_type, connections in undefined.items():
@@ -1036,7 +1036,7 @@
                                            [(input_name, None) for input_name in input_names])
                     for variable in input_variables:
                         parameter = variable.getformalParameter()
-                        if input_connected.has_key(parameter):
+                        if parameter in input_connected:
                             input_connected[parameter] = variable
                     if input_connected["EN"] is None:
                         input_connected.pop("EN")
@@ -1058,7 +1058,7 @@
                         if connections is not None:
                             if parameter != "EN":
                                 one_input_connected = True
-                            if inout_variables.has_key(parameter):
+                            if parameter in inout_variables:
                                 expression = self.ComputeExpression(body, connections, executionOrderId > 0, True)
                                 if expression is not None:
                                     inout_variables[parameter] = value
@@ -1078,7 +1078,7 @@
                 if one_input_connected:
                     for i, variable in enumerate(output_variables):
                         parameter = variable.getformalParameter()
-                        if not inout_variables.has_key(parameter) and parameter in output_names + ["", "ENO"]:
+                        if not parameter in inout_variables and parameter in output_names + ["", "ENO"]:
                             if variable.getformalParameter() == "":
                                 variable_name = "%s%d" % (type, block.getlocalId())
                             else:
@@ -1121,7 +1121,7 @@
                         input_info = (self.TagName, "block", block.getlocalId(), "input", input_idx)
                         connections = variable.connectionPointIn.getconnections()
                         if connections is not None:
-                            expression = self.ComputeExpression(body, connections, executionOrderId > 0, inout_variables.has_key(parameter))
+                            expression = self.ComputeExpression(body, connections, executionOrderId > 0, parameter in inout_variables)
                             if expression is not None:
                                 vars.append([(parameter, input_info),
                                              (" := ", ())] + self.ExtractModifier(variable, expression, input_info))
@@ -1160,7 +1160,7 @@
         if output_variable is not None:
             if block_infos["type"] == "function":
                 output_info = (self.TagName, "block", block.getlocalId(), "output", output_idx)
-                if inout_variables.has_key(output_parameter):
+                if output_parameter in inout_variables:
                     output_value = inout_variables[output_parameter]
                 else:
                     if output_parameter == "":
@@ -1519,7 +1519,7 @@
                                     transition_infos["content"] = [("\n%s:= " % self.CurrentIndent, ())] + expression + [(";\n", ())]
                                     self.SFCComputedBlocks += self.Program
                                     self.Program = []
-                    if not transition_infos.has_key("content"):
+                    if not "content" in transition_infos:
                         raise PLCGenException, _("Transition \"%s\" body must contain an output variable or coil referring to its name") % transitionValues["value"]
                 self.TagName = previous_tagname
             elif transitionValues["type"] == "connection":
--- a/ProjectController.py	Thu Aug 17 11:39:10 2017 +0300
+++ b/ProjectController.py	Thu Aug 17 14:27:06 2017 +0300
@@ -1256,7 +1256,7 @@
 
         elif name is not None and name.find("::") != -1:
             filepath, editor_name = name.split("::")
-            if not self._FileEditors.has_key(filepath):
+            if not filepath in self._FileEditors:
                 if os.path.isfile(filepath):
                     file_extension = os.path.splitext(filepath)[1]
 
@@ -1285,7 +1285,7 @@
                         if isinstance(self._FileEditors[filepath], DebugViewer):
                             self._FileEditors[filepath].SetDataProducer(self)
 
-            if self._FileEditors.has_key(filepath):
+            if filepath in self._FileEditors:
                 editor = self._FileEditors[filepath]
                 self.AppFrame.EditProjectElement(editor, editor.GetTagName())
 
@@ -1467,7 +1467,7 @@
         to a WeakKeyDictionary linking
         weakly referenced callables
         """
-        if IECPath != "__tick__" and not self._IECPathToIdx.has_key(IECPath):
+        if IECPath != "__tick__" and not IECPath in self._IECPathToIdx:
             return None
 
         self.IECdebug_lock.acquire()
@@ -1516,7 +1516,7 @@
         self.ReArmDebugRegisterTimer()
 
     def ForceDebugIECVariable(self, IECPath, fvalue):
-        if not self.IECdebug_datas.has_key(IECPath):
+        if not IECPath in self.IECdebug_datas:
             return
 
         self.IECdebug_lock.acquire()
@@ -1531,7 +1531,7 @@
         self.ReArmDebugRegisterTimer()
 
     def ReleaseDebugIECVariable(self, IECPath):
-        if not self.IECdebug_datas.has_key(IECPath):
+        if not IECPath in self.IECdebug_datas:
             return
 
         self.IECdebug_lock.acquire()
--- a/editors/TextViewer.py	Thu Aug 17 11:39:10 2017 +0300
+++ b/editors/TextViewer.py	Thu Aug 17 14:27:06 2017 +0300
@@ -495,9 +495,9 @@
                     if blocktype["type"] == "function" and blockname not in self.Keywords and blockname not in self.Variables.keys():
                         interface = dict([(name, {}) for name, type, modifier in blocktype["inputs"] + blocktype["outputs"] if name != ''])
                         for param in ["EN", "ENO"]:
-                            if not interface.has_key(param):
+                            if not param in interface:
                                 interface[param] = {}
-                        if self.Functions.has_key(blockname):
+                        if blockname in self.Functions:
                             self.Functions[blockname]["interface"].update(interface)
                             self.Functions[blockname]["extensible"] |= blocktype["extensible"]
                         else:
--- a/editors/Viewer.py	Thu Aug 17 11:39:10 2017 +0300
+++ b/editors/Viewer.py	Thu Aug 17 14:27:06 2017 +0300
@@ -2480,7 +2480,7 @@
             self.RefreshRect(self.GetScrolledRect(rect), False)
         elif not self.Debug and keycode == wx.WXK_RETURN and self.SelectedElement is not None:
             self.SelectedElement.OnLeftDClick(event, self.GetLogicalDC(), self.Scaling)
-        elif self.ARROW_KEY_MOVE.has_key(keycode):
+        elif keycode in self.ARROW_KEY_MOVE:
             move = self.ARROW_KEY_MOVE[keycode]
             if event.ControlDown() and event.ShiftDown():
                 self.Scroll({-1: 0, 0: xpos, 1: xmax}[move[0]],
--- a/plcopen/plcopen.py	Thu Aug 17 11:39:10 2017 +0300
+++ b/plcopen/plcopen.py	Thu Aug 17 14:27:06 2017 +0300
@@ -1682,7 +1682,7 @@
                 for variable in instance.inputVariables.getvariable():
                     connections = variable.connectionPointIn.getconnections()
                     if connections and len(connections) == 1:
-                        if not self.checkedBlocksDict.has_key(connections[0].getrefLocalId()):
+                        if not connections[0].getrefLocalId() in self.checkedBlocksDict:
                             self.compileelementExecutionOrder(connections[0])
                 if instance.getexecutionOrderId() == 0:
                     instance.setexecutionOrderId(self.getnewExecutionOrderId())
@@ -1866,8 +1866,8 @@
     if in_connections is not None:
         for connection in in_connections:
             connected = connection.getrefLocalId()
-            if not connections.has_key((localId, connected)) and \
-               not connections.has_key((connected, localId)):
+            if not (localId, connected) in connections and \
+               not (connected, localId) in connections:
                 connectionPointIn.remove(connection)
 
 
--- a/svgui/pyjs/build.py	Thu Aug 17 11:39:10 2017 +0300
+++ b/svgui/pyjs/build.py	Thu Aug 17 14:27:06 2017 +0300
@@ -426,7 +426,7 @@
             mod_name = pyjs.strip_py(mod_name)
 
             override_name = "%s.%s" % (platform.lower(), mod_name)
-            if pover[platform].has_key(override_name):
+            if override_name in pover[platform]:
                 mod_cache_name = "%s.cache.js" % (override_name)
             else:
                 mod_cache_name = "%s.cache.js" % (mod_name)
@@ -600,7 +600,7 @@
 
 
 def has_nodeps(mod, deps):
-    if not deps.has_key(mod) or not deps[mod]:
+    if not mod in deps or not deps[mod]:
         return True
     return False
 
--- a/svgui/pyjs/jsonrpc/django/jsonrpc.py	Thu Aug 17 11:39:10 2017 +0300
+++ b/svgui/pyjs/jsonrpc/django/jsonrpc.py	Thu Aug 17 14:27:06 2017 +0300
@@ -159,21 +159,21 @@
                 return {'success': False, 'errors': builderrors(f)}
             return {'success': True}
 
-        elif command.has_key('describe_errors'):
+        elif 'describe_errors' in command:
             field_names = command['describe_errors']
             return describe_fields_errors(f.fields, field_names)
 
-        elif command.has_key('describe'):
+        elif 'describe' in command:
             field_names = command['describe']
             return describe_fields(f.fields, field_names)
 
-        elif command.has_key('save'):
+        elif 'save' in command:
             if not f.is_valid():
                 return {'success': False, 'errors': builderrors(f)}
             instance = f.save()  # XXX: if you want more, over-ride save.
             return {'success': True, 'instance': json_convert(instance)}
 
-        elif command.has_key('html'):
+        elif 'html' in command:
             return {'success': True, 'html': f.as_table()}
 
         return "unrecognised command"
--- a/svgui/pyjs/lib/pyjslib.py	Thu Aug 17 11:39:10 2017 +0300
+++ b/svgui/pyjs/lib/pyjslib.py	Thu Aug 17 14:27:06 2017 +0300
@@ -894,11 +894,11 @@
         return self.items().__iter__()
 
     def setdefault(self, key, default_value):
-        if not self.has_key(key):
+        if not key in self:
             self[key] = default_value
 
     def get(self, key, default_=None):
-        if not self.has_key(key):
+        if not key in self:
             return default_
         return self[key]
 
--- a/svgui/pyjs/pyjs.py	Thu Aug 17 11:39:10 2017 +0300
+++ b/svgui/pyjs/pyjs.py	Thu Aug 17 14:27:06 2017 +0300
@@ -31,7 +31,7 @@
 
 prefix = sys.prefix
 
-if os.environ.has_key('PYJSPREFIX'):
+if 'PYJSPREFIX' in os.environ:
     prefix = os.environ['PYJSPREFIX']
 
 # pyjs.path is the list of paths, just like sys.path, from which
@@ -41,7 +41,7 @@
 
 path = [os.path.abspath('')]
 
-if os.environ.has_key('PYJSPATH'):
+if 'PYJSPATH' in os.environ:
     for p in os.environ['PYJSPATH'].split(os.pathsep):
         p = os.path.abspath(p)
         if os.path.isdir(p):
@@ -484,7 +484,7 @@
                 call_name = self.modpfx() + v.node.name
             elif v.node.name in self.top_level_classes:
                 call_name = self.modpfx() + v.node.name
-            elif self.imported_classes.has_key(v.node.name):
+            elif v.node.name in self.imported_classes:
                 call_name = self.imported_classes[v.node.name] + '.' + v.node.name
             elif v.node.name in PYJSLIB_BUILTIN_FUNCTIONS:
                 call_name = 'pyjslib.' + v.node.name
@@ -669,7 +669,7 @@
             return UU+self.modpfx() + v.name
         elif v.name in local_var_names:
             return v.name
-        elif self.imported_classes.has_key(v.name):
+        elif v.name in self.imported_classes:
             return UU+self.imported_classes[v.name] + '.__' + v.name + ".prototype.__class__"
         elif v.name in self.top_level_classes:
             return UU+self.modpfx() + "__" + v.name + ".prototype.__class__"
@@ -702,7 +702,7 @@
 
         if obj in self.method_imported_globals:
             call_name = UU+self.modpfx() + obj + "." + attr_name
-        elif self.imported_classes.has_key(obj):
+        elif obj in self.imported_classes:
             #attr_str = ""
             #if attr_name != "__init__":
             attr_str = ".prototype.__class__." + attr_name
@@ -770,7 +770,7 @@
             base_class = "pyjslib.__Object"
         elif len(node.bases) == 1:
             if isinstance(node.bases[0], ast.Name):
-                if self.imported_classes.has_key(node.bases[0].name):
+                if node.bases[0].name in self.imported_classes:
                     base_class_ = self.imported_classes[node.bases[0].name] + '.__' + node.bases[0].name
                     base_class = self.imported_classes[node.bases[0].name] + '.' + node.bases[0].name
                 else:
@@ -1552,7 +1552,7 @@
     def parseModule(self, module_name, file_name):
 
         importing = False
-        if not self.parse_cache.has_key(file_name):
+        if not file_name in self.parse_cache:
             importing = True
             mod = compiler.parseFile(file_name)
             self.parse_cache[file_name] = mod
--- a/svgui/svgui_server.py	Thu Aug 17 11:39:10 2017 +0300
+++ b/svgui/svgui_server.py	Thu Aug 17 14:27:06 2017 +0300
@@ -55,7 +55,7 @@
         self.inputs[attrname] = value
 
     def getinput(self, attrname, default=None):
-        if not self.inputs.has_key(attrname):
+        if not attrname in self.inputs:
             self.inputs[attrname] = default
         return self.inputs[attrname]
 
--- a/xmlclass/xmlclass.py	Thu Aug 17 11:39:10 2017 +0300
+++ b/xmlclass/xmlclass.py	Thu Aug 17 14:27:06 2017 +0300
@@ -672,12 +672,12 @@
             for element in infos["elements"]:
                 if element["type"] == CHOICE:
                     element["elmt_type"] = GenerateContentInfos(factory, name, ComputeContentChoices(factory, name, element))
-                elif choices_dict.has_key(element["name"]):
+                elif element["name"] in choices_dict:
                     raise ValueError("'%s' element defined two times in choice" % choice_name)
                 else:
                     choices_dict[element["name"]] = infos
         else:
-            if choices_dict.has_key(choice_name):
+            if choice_name in choices_dict:
                 raise ValueError("'%s' element defined two times in choice" % choice_name)
             choices_dict[choice_name] = infos
     prefix = ("%s:" % factory.TargetNamespace
@@ -743,7 +743,7 @@
                     infos = factory.GetQualifiedNameInfos(childname, namespace)
                     if infos["type"] != SYNTAXELEMENT:
                         raise ValueError("\"%s\" can't be a member child!" % name)
-                    if infos["extract"].has_key(element_name):
+                    if element_name in infos["extract"]:
                         children.append(infos["extract"][element_name](factory, child))
                     else:
                         children.append(infos["extract"]["default"](factory, child))
@@ -790,36 +790,36 @@
 
     def GetQualifiedNameInfos(self, name, namespace=None, canbenone=False):
         if namespace is None:
-            if self.Namespaces[self.SchemaNamespace].has_key(name):
+            if name in self.Namespaces[self.SchemaNamespace]:
                 return self.Namespaces[self.SchemaNamespace][name]
             for space, elements in self.Namespaces.iteritems():
-                if space != self.SchemaNamespace and elements.has_key(name):
+                if space != self.SchemaNamespace and name in elements:
                     return elements[name]
             parts = name.split("_", 1)
             if len(parts) > 1:
                 group = self.GetQualifiedNameInfos(parts[0], namespace)
                 if group is not None and group["type"] == ELEMENTSGROUP:
                     elements = []
-                    if group.has_key("elements"):
+                    if "elements" in group:
                         elements = group["elements"]
-                    elif group.has_key("choices"):
+                    elif "choices" in group:
                         elements = group["choices"]
                     for element in elements:
                         if element["name"] == parts[1]:
                             return element
             if not canbenone:
                 raise ValueError("Unknown element \"%s\" for any defined namespaces!" % name)
-        elif self.Namespaces.has_key(namespace):
-            if self.Namespaces[namespace].has_key(name):
+        elif namespace in self.Namespaces:
+            if name in self.Namespaces[namespace]:
                 return self.Namespaces[namespace][name]
             parts = name.split("_", 1)
             if len(parts) > 1:
                 group = self.GetQualifiedNameInfos(parts[0], namespace)
                 if group is not None and group["type"] == ELEMENTSGROUP:
                     elements = []
-                    if group.has_key("elements"):
+                    if "elements" in group:
                         elements = group["elements"]
-                    elif group.has_key("choices"):
+                    elif "choices" in group:
                         elements = group["choices"]
                     for element in elements:
                         if element["name"] == parts[1]:
@@ -832,36 +832,36 @@
 
     def SplitQualifiedName(self, name, namespace=None, canbenone=False):
         if namespace is None:
-            if self.Namespaces[self.SchemaNamespace].has_key(name):
+            if name in self.Namespaces[self.SchemaNamespace]:
                 return name, None
             for space, elements in self.Namespaces.items():
-                if space != self.SchemaNamespace and elements.has_key(name):
+                if space != self.SchemaNamespace and name in elements:
                     return name, None
             parts = name.split("_", 1)
             if len(parts) > 1:
                 group = self.GetQualifiedNameInfos(parts[0], namespace)
                 if group is not None and group["type"] == ELEMENTSGROUP:
                     elements = []
-                    if group.has_key("elements"):
+                    if "elements" in group:
                         elements = group["elements"]
-                    elif group.has_key("choices"):
+                    elif "choices" in group:
                         elements = group["choices"]
                     for element in elements:
                         if element["name"] == parts[1]:
                             return part[1], part[0]
             if not canbenone:
                 raise ValueError("Unknown element \"%s\" for any defined namespaces!" % name)
-        elif self.Namespaces.has_key(namespace):
-            if self.Namespaces[namespace].has_key(name):
+        elif namespace in self.Namespaces:
+            if name in self.Namespaces[namespace]:
                 return name, None
             parts = name.split("_", 1)
             if len(parts) > 1:
                 group = self.GetQualifiedNameInfos(parts[0], namespace)
                 if group is not None and group["type"] == ELEMENTSGROUP:
                     elements = []
-                    if group.has_key("elements"):
+                    if "elements" in group:
                         elements = group["elements"]
-                    elif group.has_key("choices"):
+                    elif "choices" in group:
                         elements = group["choices"]
                     for element in elements:
                         if element["name"] == parts[1]:
@@ -895,9 +895,9 @@
                 raise ValueError("Invalid attribute \"%s\" for member \"%s\"!" % (qualified_name, node.nodeName))
         for attr in valid_attrs:
             if attr not in attrs and \
-               self.Namespaces[self.SchemaNamespace].has_key(attr) and \
-               self.Namespaces[self.SchemaNamespace][attr].has_key("default"):
-                if self.Namespaces[self.SchemaNamespace][attr]["default"].has_key(element_name):
+               attr      in self.Namespaces[self.SchemaNamespace] and \
+               "default" in self.Namespaces[self.SchemaNamespace][attr]:
+                if element_name in self.Namespaces[self.SchemaNamespace][attr]["default"]:
                     default = self.Namespaces[self.SchemaNamespace][attr]["default"][element_name]
                 else:
                     default = self.Namespaces[self.SchemaNamespace][attr]["default"]["default"]
@@ -909,7 +909,7 @@
         result = []
         for child_infos in elements:
             if child_infos is not None:
-                if child_infos[1].has_key("name") and schema:
+                if "name" in child_infos[1] and schema:
                     self.CurrentCompilations.append(child_infos[1]["name"])
                 namespace, name = DecomposeQualifiedName(child_infos[0])
                 infos = self.GetQualifiedNameInfos(name, namespace)
@@ -918,7 +918,7 @@
                 element = infos["reduce"](self, child_infos[1], child_infos[2])
                 if element is not None:
                     result.append(element)
-                if child_infos[1].has_key("name") and schema:
+                if "name" in child_infos[1] and schema:
                     self.CurrentCompilations.pop(-1)
         annotations = []
         children = []
@@ -930,7 +930,7 @@
         return annotations, children
 
     def AddComplexType(self, typename, infos):
-        if not self.XMLClassDefinitions.has_key(typename):
+        if not typename in self.XMLClassDefinitions:
             self.XMLClassDefinitions[typename] = infos
         else:
             raise ValueError("\"%s\" class already defined. Choose another name!" % typename)
@@ -1032,9 +1032,9 @@
                         self.Namespaces[self.TargetNamespace][result["name"]] = result
             elif infos["type"] == ELEMENTSGROUP:
                 elements = []
-                if infos.has_key("elements"):
+                if "elements" in infos:
                     elements = infos["elements"]
-                elif infos.has_key("choices"):
+                elif "choices" in infos:
                     elements = infos["choices"]
                 for element in elements:
                     if not isinstance(element["elmt_type"], (UnicodeType, StringType)) and \
@@ -1238,7 +1238,7 @@
 def GetStructurePattern(classinfos):
     base_structure_pattern = (
         classinfos["base"].StructurePattern.pattern[:-1]
-        if classinfos.has_key("base") else "")
+        if "base" in classinfos else "")
     elements = []
     for element in classinfos["elements"]:
         if element["type"] == ANY:
@@ -1279,19 +1279,19 @@
     elements = dict([(element["name"], element) for element in classinfos["elements"]])
 
     def getattrMethod(self, name):
-        if attributes.has_key(name):
+        if name in attributes:
             attribute_infos = attributes[name]
             attribute_infos["attr_type"] = FindTypeInfos(factory, attribute_infos["attr_type"])
             value = self.get(name)
             if value is not None:
                 return attribute_infos["attr_type"]["extract"](value, extract=False)
-            elif attribute_infos.has_key("fixed"):
+            elif "fixed" in attribute_infos:
                 return attribute_infos["attr_type"]["extract"](attribute_infos["fixed"], extract=False)
-            elif attribute_infos.has_key("default"):
+            elif "default" in attribute_infos:
                 return attribute_infos["attr_type"]["extract"](attribute_infos["default"], extract=False)
             return None
 
-        elif elements.has_key(name):
+        elif name in elements:
             element_infos = elements[name]
             element_infos["elmt_type"] = FindTypeInfos(factory, element_infos["elmt_type"])
             if element_infos["type"] == CHOICE:
@@ -1320,7 +1320,7 @@
                         return element_infos["elmt_type"]["extract"](value.text, extract=False)
                     return value
 
-        elif classinfos.has_key("base"):
+        elif "base" in classinfos:
             return classinfos["base"].__getattr__(self, name)
 
         return DefaultElementClass.__getattribute__(self, name)
@@ -1334,7 +1334,7 @@
     elements = OrderedDict([(element["name"], element) for element in classinfos["elements"]])
 
     def setattrMethod(self, name, value):
-        if attributes.has_key(name):
+        if name in attributes:
             attribute_infos = attributes[name]
             attribute_infos["attr_type"] = FindTypeInfos(factory, attribute_infos["attr_type"])
             if optional_attributes.get(name, False):
@@ -1342,11 +1342,11 @@
                 if value is None or value == default:
                     self.attrib.pop(name, None)
                     return
-            elif attribute_infos.has_key("fixed"):
+            elif "fixed" in attribute_infos:
                 return
             return self.set(name, attribute_infos["attr_type"]["generate"](value))
 
-        elif elements.has_key(name):
+        elif name in elements:
             element_infos = elements[name]
             element_infos["elmt_type"] = FindTypeInfos(factory, element_infos["elmt_type"])
             if element_infos["type"] == ANY:
@@ -1388,7 +1388,7 @@
                             element = tmp_element
                         self.insert(insertion_point, element)
 
-        elif classinfos.has_key("base"):
+        elif "base" in classinfos:
             return classinfos["base"].__setattr__(self, name, value)
 
         else:
@@ -1398,9 +1398,9 @@
 
 
 def gettypeinfos(name, facets):
-    if facets.has_key("enumeration") and facets["enumeration"][0] is not None:
+    if "enumeration" in facets and facets["enumeration"][0] is not None:
         return facets["enumeration"][0]
-    elif facets.has_key("maxInclusive"):
+    elif "maxInclusive" in facets:
         limits = {"max": None, "min": None}
         if facets["maxInclusive"][0] is not None:
             limits["max"] = facets["maxInclusive"][0]
@@ -1418,7 +1418,7 @@
 def generateGetElementAttributes(factory, classinfos):
     def getElementAttributes(self):
         attr_list = []
-        if classinfos.has_key("base"):
+        if "base" in classinfos:
             attr_list.extend(classinfos["base"].getElementAttributes(self))
         for attr in classinfos["attributes"]:
             if attr["use"] != "prohibited":
@@ -1441,13 +1441,13 @@
         children = []
         if path is not None:
             parts = path.split(".", 1)
-            if attributes.has_key(parts[0]):
+            if parts[0] in attributes:
                 if len(parts) != 1:
                     raise ValueError("Wrong path!")
                 attr_type = gettypeinfos(attributes[parts[0]]["attr_type"]["basename"],
                                          attributes[parts[0]]["attr_type"]["facets"])
                 value = getattr(self, parts[0], "")
-            elif elements.has_key(parts[0]):
+            elif parts[0] in elements:
                 if elements[parts[0]]["elmt_type"]["type"] == SIMPLETYPE:
                     if len(parts) != 1:
                         raise ValueError("Wrong path!")
@@ -1464,17 +1464,17 @@
                         return attr.getElementInfos(parts[0])
                     else:
                         return attr.getElementInfos(parts[0], parts[1])
-            elif elements.has_key("content"):
+            elif "content" in elements:
                 if len(parts) > 0:
                     return self.content.getElementInfos(name, path)
-            elif classinfos.has_key("base"):
+            elif "base" in classinfos:
                 classinfos["base"].getElementInfos(name, path)
             else:
                 raise ValueError("Wrong path!")
         else:
             if not derived:
                 children.extend(self.getElementAttributes())
-            if classinfos.has_key("base"):
+            if "base" in classinfos:
                 children.extend(classinfos["base"].getElementInfos(self, name, derived=True)["children"])
             for element_name, element in elements.items():
                 if element["minOccurs"] == 0:
@@ -1508,13 +1508,13 @@
     def setElementValue(self, path, value):
         if path is not None:
             parts = path.split(".", 1)
-            if attributes.has_key(parts[0]):
+            if parts[0] in attributes:
                 if len(parts) != 1:
                     raise ValueError("Wrong path!")
                 if attributes[parts[0]]["attr_type"]["basename"] == "boolean":
                     setattr(self, parts[0], value)
                 elif attributes[parts[0]]["use"] == "optional" and value == "":
-                    if attributes[parts[0]].has_key("default"):
+                    if "default" in attributes[parts[0]]:
                         setattr(self, parts[0],
                             attributes[parts[0]]["attr_type"]["extract"](
                                 attributes[parts[0]]["default"], False))
@@ -1522,7 +1522,7 @@
                         setattr(self, parts[0], None)
                 else:
                     setattr(self, parts[0], attributes[parts[0]]["attr_type"]["extract"](value, False))
-            elif elements.has_key(parts[0]):
+            elif parts[0] in elements:
                 if elements[parts[0]]["elmt_type"]["type"] == SIMPLETYPE:
                     if len(parts) != 1:
                         raise ValueError("Wrong path!")
@@ -1542,12 +1542,12 @@
                             instance.setElementValue(parts[1], value)
                         else:
                             instance.setElementValue(None, value)
-            elif elements.has_key("content"):
+            elif "content" in elements:
                 if len(parts) > 0:
                     self.content.setElementValue(path, value)
-            elif classinfos.has_key("base"):
+            elif "base" in classinfos:
                 classinfos["base"].setElementValue(self, path, value)
-        elif elements.has_key("content"):
+        elif "content" in elements:
             if value == "":
                 if elements["content"]["minOccurs"] == 0:
                     self.setcontent([])
@@ -1564,7 +1564,7 @@
     """
 
     def initMethod(self):
-        if classinfos.has_key("base"):
+        if "base" in classinfos:
             classinfos["base"]._init_(self)
         for attribute in classinfos["attributes"]:
             attribute["attr_type"] = FindTypeInfos(factory, attribute["attr_type"])
@@ -1598,7 +1598,7 @@
     def addMethod(self):
         if infos["type"] == ATTRIBUTE:
             infos["attr_type"] = FindTypeInfos(factory, infos["attr_type"])
-            if not infos.has_key("default"):
+            if not "default" in infos:
                 setattr(self, attr, infos["attr_type"]["initial"]())
         elif infos["type"] == ELEMENT:
             infos["elmt_type"] = FindTypeInfos(factory, infos["elmt_type"])
@@ -1657,7 +1657,7 @@
     choices = dict([(choice["name"], choice) for choice in choice_types])
 
     def setChoiceMethod(self, content_type):
-        if not choices.has_key(content_type):
+        if not content_type in choices:
             raise ValueError("Unknown \"%s\" choice type for \"content\"!" % content_type)
         choices[content_type]["elmt_type"] = FindTypeInfos(factory, choices[content_type]["elmt_type"])
         new_content = choices[content_type]["elmt_type"]["initial"]()
@@ -1671,7 +1671,7 @@
     choices = dict([(choice["name"], choice) for choice in choice_types])
 
     def appendChoiceMethod(self, content_type):
-        if not choices.has_key(content_type):
+        if not content_type in choices:
             raise ValueError("Unknown \"%s\" choice type for \"content\"!" % content_type)
         choices[content_type]["elmt_type"] = FindTypeInfos(factory, choices[content_type]["elmt_type"])
         if maxOccurs == "unbounded" or len(self.content) < maxOccurs:
@@ -1688,7 +1688,7 @@
     choices = dict([(choice["name"], choice) for choice in choice_types])
 
     def insertChoiceMethod(self, index, content_type):
-        if not choices.has_key(content_type):
+        if not content_type in choices:
             raise ValueError("Unknown \"%s\" choice type for \"content\"!" % content_type)
         choices[type]["elmt_type"] = FindTypeInfos(factory, choices[content_type]["elmt_type"])
         if maxOccurs == "unbounded" or len(self.content) < maxOccurs:
--- a/xmlclass/xsdschema.py	Thu Aug 17 11:39:10 2017 +0300
+++ b/xmlclass/xsdschema.py	Thu Aug 17 14:27:06 2017 +0300
@@ -107,7 +107,7 @@
                 text = "(source: %(source)s):\n%(content)s\n\n" % child
             else:
                 text = child["content"] + "\n\n"
-            if not annotation["documentation"].has_key(child["language"]):
+            if not child["language"] in annotation["documentation"]:
                 annotation["documentation"] = text
             else:
                 annotation["documentation"] += text
@@ -119,7 +119,7 @@
 def GenerateFacetReducing(facetname, canbefixed):
     def ReduceFacet(factory, attributes, elements):
         annotations, children = factory.ReduceElements(elements)
-        if attributes.has_key("value"):
+        if "value" in attributes:
             facet = {"type": facetname, "value": attributes["value"], "doc": annotations}
             if canbefixed:
                 facet["fixed"] = attributes.get("fixed", False)
@@ -158,7 +158,7 @@
     # Initialize type informations
     facets = {}
     simpleType = {"type": SIMPLETYPE, "final": attributes.get("final", [])}
-    if attributes.has_key("name"):
+    if "name" in attributes:
         simpleType["name"] = attributes["name"]
 
     if typeinfos["type"] in ["restriction", "extension"]:
@@ -177,7 +177,7 @@
         simpleType["basename"] = basetypeinfos["basename"]
 
         # Check that derivation is allowed
-        if basetypeinfos.has_key("final"):
+        if "final" in basetypeinfos:
             if "#all" in basetypeinfos["final"]:
                 raise ValueError("Base type can't be derivated!")
             if "restriction" in basetypeinfos["final"] and typeinfos["type"] == "restriction":
@@ -186,7 +186,7 @@
         # Extract simple type facets
         for facet in typeinfos.get("facets", []):
             facettype = facet["type"]
-            if not basetypeinfos["facets"].has_key(facettype):
+            if not facettype in basetypeinfos["facets"]:
                 raise ValueError("\"%s\" facet can't be defined for \"%s\" type!" % (facettype, type))
             elif basetypeinfos["facets"][facettype][1]:
                 raise ValueError("\"%s\" facet is fixed on base type!" % facettype)
@@ -202,16 +202,16 @@
                     continue
                 else:
                     raise ValueError("\"%s\" facet can't be defined with another facet type!" % facettype)
-            elif facets.has_key("enumeration"):
+            elif "enumeration" in facets:
                 raise ValueError("\"enumeration\" facet can't be defined with another facet type!")
-            elif facets.has_key("pattern"):
+            elif "pattern" in facets:
                 raise ValueError("\"pattern\" facet can't be defined with another facet type!")
-            elif facets.has_key(facettype):
+            elif facettype in facets:
                 raise ValueError("\"%s\" facet can't be defined two times!" % facettype)
             elif facettype == "length":
-                if facets.has_key("minLength"):
+                if "minLength" in facets:
                     raise ValueError("\"length\" and \"minLength\" facets can't be defined at the same time!")
-                if facets.has_key("maxLength"):
+                if "maxLength" in facets:
                     raise ValueError("\"length\" and \"maxLength\" facets can't be defined at the same time!")
                 try:
                     value = int(value)
@@ -222,7 +222,7 @@
                 elif basevalue is not None and basevalue != value:
                     raise ValueError("\"length\" can't be different from \"length\" defined in base type!")
             elif facettype == "minLength":
-                if facets.has_key("length"):
+                if "length" in facets:
                     raise ValueError("\"length\" and \"minLength\" facets can't be defined at the same time!")
                 try:
                     value = int(value)
@@ -230,12 +230,12 @@
                     raise ValueError("\"minLength\" must be an integer!")
                 if value < 0:
                     raise ValueError("\"minLength\" can't be negative!")
-                elif facets.has_key("maxLength") and value > facets["maxLength"]:
+                elif "maxLength" in facets and value > facets["maxLength"]:
                     raise ValueError("\"minLength\" must be lesser than or equal to \"maxLength\"!")
                 elif basevalue is not None and basevalue < value:
                     raise ValueError("\"minLength\" can't be lesser than \"minLength\" defined in base type!")
             elif facettype == "maxLength":
-                if facets.has_key("length"):
+                if "length" in facets:
                     raise ValueError("\"length\" and \"maxLength\" facets can't be defined at the same time!")
                 try:
                     value = int(value)
@@ -243,52 +243,52 @@
                     raise ValueError("\"maxLength\" must be an integer!")
                 if value < 0:
                     raise ValueError("\"maxLength\" can't be negative!")
-                elif facets.has_key("minLength") and value < facets["minLength"]:
+                elif "minLength" in facets and value < facets["minLength"]:
                     raise ValueError("\"minLength\" must be lesser than or equal to \"maxLength\"!")
                 elif basevalue is not None and basevalue > value:
                     raise ValueError("\"maxLength\" can't be greater than \"maxLength\" defined in base type!")
             elif facettype == "minInclusive":
-                if facets.has_key("minExclusive"):
+                if "minExclusive" in facets:
                     raise ValueError("\"minExclusive\" and \"minInclusive\" facets can't be defined at the same time!")
                 value = basetypeinfos["extract"](facet["value"], False)
-                if facets.has_key("maxInclusive") and value > facets["maxInclusive"][0]:
+                if "maxInclusive" in facets and value > facets["maxInclusive"][0]:
                     raise ValueError("\"minInclusive\" must be lesser than or equal to \"maxInclusive\"!")
-                elif facets.has_key("maxExclusive") and value >= facets["maxExclusive"][0]:
+                elif "maxExclusive" in facets and value >= facets["maxExclusive"][0]:
                     raise ValueError("\"minInclusive\" must be lesser than \"maxExclusive\"!")
             elif facettype == "minExclusive":
-                if facets.has_key("minInclusive"):
+                if "minInclusive" in facets:
                     raise ValueError("\"minExclusive\" and \"minInclusive\" facets can't be defined at the same time!")
                 value = basetypeinfos["extract"](facet["value"], False)
-                if facets.has_key("maxInclusive") and value >= facets["maxInclusive"][0]:
+                if "maxInclusive" in facets and value >= facets["maxInclusive"][0]:
                     raise ValueError("\"minExclusive\" must be lesser than \"maxInclusive\"!")
-                elif facets.has_key("maxExclusive") and value >= facets["maxExclusive"][0]:
+                elif "maxExclusive" in facets and value >= facets["maxExclusive"][0]:
                     raise ValueError("\"minExclusive\" must be lesser than \"maxExclusive\"!")
             elif facettype == "maxInclusive":
-                if facets.has_key("maxExclusive"):
+                if "maxExclusive" in facets:
                     raise ValueError("\"maxExclusive\" and \"maxInclusive\" facets can't be defined at the same time!")
                 value = basetypeinfos["extract"](facet["value"], False)
-                if facets.has_key("minInclusive") and value < facets["minInclusive"][0]:
+                if "minInclusive" in facets and value < facets["minInclusive"][0]:
                     raise ValueError("\"minInclusive\" must be lesser than or equal to \"maxInclusive\"!")
-                elif facets.has_key("minExclusive") and value <= facets["minExclusive"][0]:
+                elif "minExclusive" in facets and value <= facets["minExclusive"][0]:
                     raise ValueError("\"minExclusive\" must be lesser than \"maxInclusive\"!")
             elif facettype == "maxExclusive":
-                if facets.has_key("maxInclusive"):
+                if "maxInclusive" in facets:
                     raise ValueError("\"maxExclusive\" and \"maxInclusive\" facets can't be defined at the same time!")
                 value = basetypeinfos["extract"](facet["value"], False)
-                if facets.has_key("minInclusive") and value <= facets["minInclusive"][0]:
+                if "minInclusive" in facets and value <= facets["minInclusive"][0]:
                     raise ValueError("\"minInclusive\" must be lesser than \"maxExclusive\"!")
-                elif facets.has_key("minExclusive") and value <= facets["minExclusive"][0]:
+                elif "minExclusive" in facets and value <= facets["minExclusive"][0]:
                     raise ValueError("\"minExclusive\" must be lesser than \"maxExclusive\"!")
             elif facettype == "whiteSpace":
                 if basevalue == "collapse" and value in ["preserve", "replace"] or basevalue == "replace" and value == "preserve":
                     raise ValueError("\"whiteSpace\" is incompatible with \"whiteSpace\" defined in base type!")
             elif facettype == "totalDigits":
-                if facets.has_key("fractionDigits") and value <= facets["fractionDigits"][0]:
+                if "fractionDigits" in facets and value <= facets["fractionDigits"][0]:
                     raise ValueError("\"fractionDigits\" must be lesser than or equal to \"totalDigits\"!")
                 elif basevalue is not None and value > basevalue:
                     raise ValueError("\"totalDigits\" can't be greater than \"totalDigits\" defined in base type!")
             elif facettype == "fractionDigits":
-                if facets.has_key("totalDigits") and value <= facets["totalDigits"][0]:
+                if "totalDigits" in facets and value <= facets["totalDigits"][0]:
                     raise ValueError("\"fractionDigits\" must be lesser than or equal to \"totalDigits\"!")
                 elif basevalue is not None and value > basevalue:
                     raise ValueError("\"totalDigits\" can't be greater than \"totalDigits\" defined in base type!")
@@ -296,7 +296,7 @@
 
         # Report not redefined facet from base type to new created type
         for facettype, facetvalue in basetypeinfos["facets"].items():
-            if not facets.has_key(facettype):
+            if not facettype in facets:
                 facets[facettype] = facetvalue
 
         # Generate extract value for new created type
@@ -401,10 +401,10 @@
         simpleType["basename"] = "list"
 
         # Check that derivation is allowed
-        if itemtypeinfos.has_key("final"):
-            if itemtypeinfos["final"].has_key("#all"):
+        if "final" in itemtypeinfos:
+            if "#all" in itemtypeinfos["final"]:
                 raise ValueError("Item type can't be derivated!")
-            if itemtypeinfos["final"].has_key("list"):
+            if "list" in itemtypeinfos["final"]:
                 raise ValueError("Item type can't be derivated by list!")
 
         # Generate extract value for new created type
@@ -445,10 +445,10 @@
                 raise ValueError("Member type given isn't a simpleType!")
 
             # Check that derivation is allowed
-            if infos.has_key("final"):
-                if infos["final"].has_key("#all"):
+            if "final" in infos:
+                if "#all" in infos["final"]:
                     raise ValueError("Item type can't be derivated!")
-                if infos["final"].has_key("union"):
+                if "union" in infos["final"]:
                     raise ValueError("Member type can't be derivated by union!")
 
             membertypesinfos.append(infos)
@@ -553,7 +553,7 @@
 
 def ReduceExtension(factory, attributes, elements):
     annotations, children = factory.ReduceElements(elements)
-    if not attributes.has_key("base"):
+    if not "base" in attributes:
         raise ValueError("No base type has been defined for extension!")
     extension = {"type": "extension", "attributes": [], "elements": [], "base": attributes["base"], "doc": annotations}
     if len(children) > 0:
@@ -568,7 +568,7 @@
                 extension["elements"].append(content)
             elif group["type"] == "group":
                 elmtgroup = factory.FindSchemaElement(child["ref"], ELEMENTSGROUP)
-                if elmtgroup.has_key("elements"):
+                if "elements" in elmtgroup:
                     extension["elements"] = elmtgroup["elements"]
                     extension["order"] = elmtgroup["order"]
                 else:
@@ -591,7 +591,7 @@
     elif basetypeinfos["type"] == COMPLEXTYPE and \
          len(basetypeinfos["elements"]) == 1 and \
          basetypeinfos["elements"][0]["name"] == "content" and \
-         basetypeinfos["elements"][0].has_key("elmt_type") and \
+         "elmt_type" in basetypeinfos["elements"][0] and \
          basetypeinfos["elements"][0]["elmt_type"]["type"] == SIMPLETYPE:
         contenttypeinfos = simpleContent.copy()
         contenttypeinfos["base"] = basetypeinfos["elements"][0]["elmt_type"]
@@ -651,7 +651,7 @@
                 complexType["elements"].append(content)
             elif group["type"] == "group":
                 elmtgroup = factory.FindSchemaElement(child["ref"], ELEMENTSGROUP)
-                if elmtgroup.has_key("elements"):
+                if "elements" in elmtgroup:
                     complexType["elements"] = elmtgroup["elements"]
                     complexType["order"] = elmtgroup["order"]
                 else:
@@ -677,8 +677,8 @@
 def ReduceAttribute(factory, attributes, elements):
     annotations, children = factory.ReduceElements(elements)
 
-    if attributes.has_key("default"):
-        if attributes.has_key("fixed"):
+    if "default" in attributes:
+        if "fixed" in attributes:
             raise ValueError("\"default\" and \"fixed\" can't be defined at the same time!")
         elif attributes.get("use", "optional") != "optional":
             raise ValueError("if \"default\" present, \"use\" can only have the value \"optional\"!")
@@ -690,17 +690,17 @@
         else:
             raise ValueError("Only one type can be defined for attribute!")
 
-    if attributes.has_key("ref"):
-        if attributes.has_key("name"):
+    if "ref" in attributes:
+        if "name" in attributes:
             raise ValueError("\"ref\" and \"name\" can't be defined at the same time!")
-        elif attributes.has_key("form"):
+        elif "form" in attributes:
             raise ValueError("\"ref\" and \"form\" can't be defined at the same time!")
         elif attribute["attr_type"] is not None:
             raise ValueError("if \"ref\" is present, no type can be defined!")
     elif attribute["attr_type"] is None:
         raise ValueError("No type has been defined for attribute \"%s\"!" % attributes["name"])
 
-    if attributes.has_key("type"):
+    if "type" in attributes:
         tmp_attrs = attributes.copy()
         tmp_attrs.pop("type")
         attribute.update(tmp_attrs)
@@ -711,7 +711,7 @@
 
 def ReduceAttributeGroup(factory, attributes, elements):
     annotations, children = factory.ReduceElements(elements)
-    if attributes.has_key("ref"):
+    if "ref" in attributes:
         return {"type": "attributeGroup", "ref": attributes["ref"], "doc": annotations}
     else:
         return {"type": ATTRIBUTESGROUP, "attributes": ExtractAttributes(factory, children), "doc": annotations}
@@ -738,14 +738,14 @@
         else:
             types.append(child)
 
-    if attributes.has_key("default") and attributes.has_key("fixed"):
+    if "default" in attributes and "fixed" in attributes:
         raise ValueError("\"default\" and \"fixed\" can't be defined at the same time!")
 
-    if attributes.has_key("ref"):
+    if "ref" in attributes:
         for attr in ["name", "default", "fixed", "form", "block", "type"]:
-            if attributes.has_key(attr):
+            if attr in attributes:
                 raise ValueError("\"ref\" and \"%s\" can't be defined at the same time!" % attr)
-        if attributes.has_key("nillable"):
+        if "nillable" in attributes:
             raise ValueError("\"ref\" and \"nillable\" can't be defined at the same time!")
         if len(types) > 0:
             raise ValueError("No type and no constraints can be defined where \"ref\" is defined!")
@@ -760,7 +760,7 @@
         else:
             raise ValueError("\"%s\" base type isn't defined or circular referenced!" % name)
 
-    elif attributes.has_key("name"):
+    elif "name" in attributes:
         element = {"type": ELEMENT, "elmt_type": attributes.get("type", None), "constraints": constraints, "doc": annotations}
         if len(types) > 0:
             if element["elmt_type"] is None:
@@ -771,7 +771,7 @@
             element["elmt_type"] = "tag"
             element["type"] = TAG
 
-        if attributes.has_key("type"):
+        if "type" in attributes:
             tmp_attrs = attributes.copy()
             tmp_attrs.pop("type")
             element.update(tmp_attrs)
@@ -808,7 +808,7 @@
             choices.extend(child["choices"])
         elif child["type"] == "group":
             elmtgroup = factory.FindSchemaElement(child["ref"], ELEMENTSGROUP)
-            if not elmtgroup.has_key("choices"):
+            if not "choices" in elmtgroup:
                 raise ValueError("Only group composed of \"choice\" can be referenced in \"choice\" element!")
             choices_tmp = []
             for choice in elmtgroup["choices"]:
@@ -842,7 +842,7 @@
             sequence.extend(child["elements"])
         elif child["type"] == "group":
             elmtgroup = factory.FindSchemaElement(child["ref"], ELEMENTSGROUP)
-            if not elmtgroup.has_key("elements") or not elmtgroup["order"]:
+            if not "elements" in elmtgroup or not elmtgroup["order"]:
                 raise ValueError("Only group composed of \"sequence\" can be referenced in \"sequence\" element!")
             elements_tmp = []
             for element in elmtgroup["elements"]:
@@ -864,7 +864,7 @@
 def ReduceGroup(factory, attributes, elements):
     annotations, children = factory.ReduceElements(elements)
 
-    if attributes.has_key("ref"):
+    if "ref" in attributes:
         return {"type": "group", "ref": attributes["ref"], "doc": annotations}
     else:
         element = children[0]
@@ -973,7 +973,7 @@
     annotations, children = factory.ReduceElements(elements, True)
 
     for child in children:
-        if child.has_key("name"):
+        if "name" in child:
             infos = factory.GetQualifiedNameInfos(child["name"], factory.TargetNamespace, True)
             if infos is None:
                 factory.Namespaces[factory.TargetNamespace][child["name"]] = child