# HG changeset patch # User Andrey Skvortsov # Date 1539248440 -10800 # Node ID 5024c19ca8f050a00f99870eedbb550fb99eb984 # Parent b0560adec4b71c4bcd96af0db9ccaeb436da8203 python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module diff -r b0560adec4b7 -r 5024c19ca8f0 BeremizIDE.py --- a/BeremizIDE.py Thu Oct 11 10:25:19 2018 +0300 +++ b/BeremizIDE.py Thu Oct 11 12:00:40 2018 +0300 @@ -30,7 +30,6 @@ import tempfile import shutil import random -import types import time from time import time as gettime from threading import Lock, Timer, currentThread @@ -717,7 +716,7 @@ def GenerateMenuRecursive(self, items, menu): for kind, infos in items: - if isinstance(kind, types.ListType): + if isinstance(kind, list): text, id = infos submenu = wx.Menu('') self.GenerateMenuRecursive(kind, submenu) diff -r b0560adec4b7 -r 5024c19ca8f0 Beremiz_service.py --- a/Beremiz_service.py Thu Oct 11 10:25:19 2018 +0300 +++ b/Beremiz_service.py Thu Oct 11 12:00:40 2018 +0300 @@ -32,6 +32,7 @@ import threading from threading import Thread, Semaphore, Lock import traceback +from builtins import str as text from past.builtins import execfile from six.moves import builtins import Pyro @@ -203,7 +204,6 @@ if havewx: import re - from types import * if wx.VERSION >= (3, 0, 0): app = wx.App(redirect=False) @@ -338,7 +338,7 @@ def OnTaskBarChangePort(self, evt): dlg = ParamsEntryDialog(None, _("Enter a port number "), defaultValue=str(self.pyroserver.port)) - dlg.SetTests([(UnicodeType.isdigit, _("Port number must be an integer!")), (lambda port: 0 <= int(port) <= 65535, _("Port number must be 0 <= port <= 65535!"))]) + dlg.SetTests([(text.isdigit, _("Port number must be an integer!")), (lambda port: 0 <= int(port) <= 65535, _("Port number must be 0 <= port <= 65535!"))]) if dlg.ShowModal() == wx.ID_OK: self.pyroserver.port = int(dlg.GetValue()) self.pyroserver.Restart() diff -r b0560adec4b7 -r 5024c19ca8f0 IDEFrame.py --- a/IDEFrame.py Thu Oct 11 10:25:19 2018 +0300 +++ b/IDEFrame.py Thu Oct 11 12:00:40 2018 +0300 @@ -25,7 +25,6 @@ from __future__ import absolute_import from __future__ import division import sys -from types import TupleType import base64 from builtins import str as text @@ -835,7 +834,7 @@ return None def LoadTabLayout(self, notebook, tabs, mode="all", first_index=None): - if isinstance(tabs, ListType): + if isinstance(tabs, list): if len(tabs) == 0: return raise ValueError("Not supported") @@ -2437,7 +2436,7 @@ result = self.Controler.PastePou(pou_type, pou_xml) - if not isinstance(result, TupleType): + if not isinstance(result, tuple): self.ShowErrorMessage(result) else: self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, PROJECTTREE, LIBRARYTREE) diff -r b0560adec4b7 -r 5024c19ca8f0 PLCControler.py --- a/PLCControler.py Thu Oct 11 10:25:19 2018 +0300 +++ b/PLCControler.py Thu Oct 11 12:00:40 2018 +0300 @@ -26,7 +26,6 @@ from __future__ import absolute_import from __future__ import division -from types import TupleType from copy import deepcopy import os import re @@ -874,7 +873,7 @@ tempvar.setname(var.Name) var_type = PLCOpenParser.CreateElement("type", "variable") - if isinstance(var.Type, TupleType): + if isinstance(var.Type, tuple): if var.Type[0] == "array": _array_type, base_type_name, dimensions = var.Type array = PLCOpenParser.CreateElement("array", "dataType") @@ -1367,7 +1366,7 @@ return True def IsLocatableType(self, typename, debug=False): - if isinstance(typename, TupleType) or self.GetBlockType(typename) is not None: + if isinstance(typename, tuple) or self.GetBlockType(typename) is not None: return False # the size of these types is implementation dependend @@ -1380,7 +1379,7 @@ return True def IsEnumeratedType(self, typename, debug=False): - if isinstance(typename, TupleType): + if isinstance(typename, tuple): typename = typename[1] datatype = self.GetDataType(typename, debug) if datatype is not None: @@ -1394,7 +1393,7 @@ def IsSubrangeType(self, typename, exclude=None, debug=False): if typename == exclude: return False - if isinstance(typename, TupleType): + if isinstance(typename, tuple): typename = typename[1] datatype = self.GetDataType(typename, debug) if datatype is not None: @@ -1613,7 +1612,7 @@ element = PLCOpenParser.CreateElement("variable", "struct") element.setname(element_infos["Name"]) element_type = PLCOpenParser.CreateElement("type", "variable") - if isinstance(element_infos["Type"], TupleType): + if isinstance(element_infos["Type"], tuple): if element_infos["Type"][0] == "array": _array_type, base_type_name, dimensions = element_infos["Type"] array = PLCOpenParser.CreateElement("array", "dataType") diff -r b0560adec4b7 -r 5024c19ca8f0 PLCGenerator.py --- a/PLCGenerator.py Thu Oct 11 10:25:19 2018 +0300 +++ b/PLCGenerator.py Thu Oct 11 12:00:40 2018 +0300 @@ -24,7 +24,6 @@ from __future__ import absolute_import -from types import * import re from six.moves import xrange @@ -710,7 +709,7 @@ def ComputeConnectionTypes(self, pou): body = pou.getbody() - if isinstance(body, ListType): + if isinstance(body, list): body = body[0] body_content = body.getcontent() body_type = body_content.getLocalTag() @@ -943,7 +942,7 @@ def ComputeProgram(self, pou): body = pou.getbody() - if isinstance(body, ListType): + if isinstance(body, list): body = body[0] body_content = body.getcontent() body_type = body_content.getLocalTag() @@ -1051,7 +1050,7 @@ uncomputed_index = range(len(paths)) factorized_paths = [] for num, path in enumerate(paths): - if isinstance(path, ListType): + if isinstance(path, list): if len(path) > 1: str_path = str(path[-1:]) same_paths.setdefault(str_path, []) @@ -1341,7 +1340,7 @@ paths.append([variable, tuple(factorized_paths)]) else: paths.append([variable] + factorized_paths) - elif isinstance(result[0], ListType): + elif isinstance(result[0], list): paths.append([variable] + result[0]) elif result[0] is not None: paths.append([variable, result[0]]) @@ -1352,7 +1351,7 @@ return paths def ComputePaths(self, paths, first=False): - if isinstance(paths, TupleType): + if isinstance(paths, tuple): if None in paths: return [("TRUE", ())] else: @@ -1361,7 +1360,7 @@ return JoinList([(" OR ", ())], vars) else: return [("(", ())] + JoinList([(" OR ", ())], vars) + [(")", ())] - elif isinstance(paths, ListType): + elif isinstance(paths, list): vars = [self.ComputePaths(path) for path in paths] return JoinList([(" AND ", ())], vars) elif paths is None: @@ -1423,7 +1422,7 @@ if connections is not None and len(connections) == 1: instanceLocalId = connections[0].getrefLocalId() body = pou.getbody() - if isinstance(body, ListType): + if isinstance(body, list): body = body[0] return body.getcontentInstance(instanceLocalId) return None @@ -1435,7 +1434,7 @@ if connections is not None and len(connections) == 1: instanceLocalId = connections[0].getrefLocalId() body = pou.getbody() - if isinstance(body, ListType): + if isinstance(body, list): body = body[0] instances.append(body.getcontentInstance(instanceLocalId)) return instances @@ -1456,7 +1455,7 @@ if connections is not None and len(connections) == 1: instanceLocalId = connections[0].getrefLocalId() body = pou.getbody() - if isinstance(body, ListType): + if isinstance(body, list): body = body[0] instance = body.getcontentInstance(instanceLocalId) if isinstance(instance, TransitionClass): @@ -1490,7 +1489,7 @@ if connections is not None and len(connections) == 1: instanceLocalId = connections[0].getrefLocalId() body = pou.getbody() - if isinstance(body, ListType): + if isinstance(body, list): body = body[0] instance = body.getcontentInstance(instanceLocalId) if isinstance(instance, TransitionClass): @@ -1515,7 +1514,7 @@ if connections is not None and len(connections) == 1: stepLocalId = connections[0].getrefLocalId() body = pou.getbody() - if isinstance(body, ListType): + if isinstance(body, list): body = body[0] step = body.getcontentInstance(stepLocalId) self.GenerateSFCStep(step, pou) @@ -1562,7 +1561,7 @@ if connections is not None and len(connections) == 1: instanceLocalId = connections[0].getrefLocalId() body = pou.getbody() - if isinstance(body, ListType): + if isinstance(body, list): body = body[0] instance = body.getcontentInstance(instanceLocalId) if isinstance(instance, StepClass): @@ -1617,7 +1616,7 @@ self.TagName = previous_tagname elif transitionValues["type"] == "connection": body = pou.getbody() - if isinstance(body, ListType): + if isinstance(body, list): body = body[0] connections = transitionValues["value"].getconnections() if connections is not None: diff -r b0560adec4b7 -r 5024c19ca8f0 ProjectController.py --- a/ProjectController.py Thu Oct 11 10:25:19 2018 +0300 +++ b/ProjectController.py Thu Oct 11 12:00:40 2018 +0300 @@ -36,7 +36,6 @@ import shutil import re import tempfile -from types import ListType from threading import Timer from datetime import datetime from weakref import WeakKeyDictionary @@ -73,7 +72,7 @@ def ExtractChildrenTypesFromCatalog(catalog): children_types = [] for n, d, _h, c in catalog: - if isinstance(c, ListType): + if isinstance(c, list): children_types.extend(ExtractChildrenTypesFromCatalog(c)) else: children_types.append((n, GetClassImporter(c), d)) @@ -83,7 +82,7 @@ def ExtractMenuItemsFromCatalog(catalog): menu_items = [] for n, d, h, c in catalog: - if isinstance(c, ListType): + if isinstance(c, list): children = ExtractMenuItemsFromCatalog(c) else: children = [] diff -r b0560adec4b7 -r 5024c19ca8f0 canfestival/config_utils.py --- a/canfestival/config_utils.py Thu Oct 11 10:25:19 2018 +0300 +++ b/canfestival/config_utils.py Thu Oct 11 12:00:40 2018 +0300 @@ -28,7 +28,7 @@ import os import sys import getopt -from types import * +from past.builtins import long # Translation between IEC types and Can Open types IECToCOType = { @@ -465,7 +465,7 @@ # Indicate that this PDO entry must be saved if locationinfos["bit"] is not None: - if not isinstance(self.MasterMapping[cobid]["mapping"][subindex], ListType): + if not isinstance(self.MasterMapping[cobid]["mapping"][subindex], list): self.MasterMapping[cobid]["mapping"][subindex] = [1] * self.MasterMapping[cobid]["mapping"][subindex] if locationinfos["bit"] < len(self.MasterMapping[cobid]["mapping"][subindex]): self.MasterMapping[cobid]["mapping"][subindex][locationinfos["bit"]] = (locationinfos["type"], name) @@ -557,7 +557,7 @@ mapping = [] for item in pdo_infos["mapping"]: - if isinstance(item, ListType): + if isinstance(item, list): mapping.extend(item) else: mapping.append(item) @@ -572,7 +572,7 @@ continue new_index = False - if isinstance(variable, (IntType, LongType)): + if isinstance(variable, (int, long)): # If variable is an integer then variable is unexpected self.MasterNode.SetEntry(current_idx + 0x200, subindex, self.TrashVariables[variable]) else: diff -r b0560adec4b7 -r 5024c19ca8f0 controls/DebugVariablePanel/DebugVariableGraphicViewer.py --- a/controls/DebugVariablePanel/DebugVariableGraphicViewer.py Thu Oct 11 10:25:19 2018 +0300 +++ b/controls/DebugVariablePanel/DebugVariableGraphicViewer.py Thu Oct 11 12:00:40 2018 +0300 @@ -25,7 +25,6 @@ from __future__ import absolute_import from __future__ import division -from types import TupleType from time import time as gettime from cycler import cycler @@ -158,7 +157,7 @@ # Check that data is valid regarding DebugVariablePanel try: values = eval(data) - if not isinstance(values, TupleType): + if not isinstance(values, tuple): raise ValueError except Exception: message = _("Invalid value \"%s\" for debug variable") % data diff -r b0560adec4b7 -r 5024c19ca8f0 controls/DebugVariablePanel/DebugVariablePanel.py --- a/controls/DebugVariablePanel/DebugVariablePanel.py Thu Oct 11 10:25:19 2018 +0300 +++ b/controls/DebugVariablePanel/DebugVariablePanel.py Thu Oct 11 12:00:40 2018 +0300 @@ -25,7 +25,6 @@ from __future__ import absolute_import from __future__ import division -from types import TupleType import numpy import wx @@ -124,7 +123,7 @@ # Check that data is valid regarding DebugVariablePanel try: values = eval(data) - if not isinstance(values, TupleType): + if not isinstance(values, tuple): raise ValueError except Exception: message = _("Invalid value \"%s\" for debug variable") % data diff -r b0560adec4b7 -r 5024c19ca8f0 controls/DebugVariablePanel/DebugVariableTextViewer.py --- a/controls/DebugVariablePanel/DebugVariableTextViewer.py Thu Oct 11 10:25:19 2018 +0300 +++ b/controls/DebugVariablePanel/DebugVariableTextViewer.py Thu Oct 11 12:00:40 2018 +0300 @@ -25,7 +25,6 @@ from __future__ import absolute_import from __future__ import division -from types import TupleType import wx @@ -88,7 +87,7 @@ # Check that data is valid regarding DebugVariablePanel try: values = eval(data) - if not isinstance(values, TupleType): + if not isinstance(values, tuple): raise ValueError except Exception: message = _("Invalid value \"%s\" for debug variable") % data diff -r b0560adec4b7 -r 5024c19ca8f0 controls/SearchResultPanel.py --- a/controls/SearchResultPanel.py Thu Oct 11 10:25:19 2018 +0300 +++ b/controls/SearchResultPanel.py Thu Oct 11 12:00:40 2018 +0300 @@ -24,7 +24,6 @@ from __future__ import absolute_import -from types import TupleType import wx import wx.lib.buttons @@ -324,7 +323,7 @@ def ShowSearchResults(self, item): data = self.SearchResultsTree.GetPyData(item) - if isinstance(data, TupleType): + if isinstance(data, tuple): search_results = [data] else: search_results = self.SearchResults.get(data, []) diff -r b0560adec4b7 -r 5024c19ca8f0 controls/VariablePanel.py --- a/controls/VariablePanel.py Thu Oct 11 10:25:19 2018 +0300 +++ b/controls/VariablePanel.py Thu Oct 11 12:00:40 2018 +0300 @@ -26,12 +26,12 @@ from __future__ import absolute_import from __future__ import division import re -from types import TupleType, StringType, UnicodeType from builtins import str as text import wx import wx.grid import wx.lib.buttons +from six import string_types from six.moves import xrange from plcopen.structures import LOCATIONDATATYPES, TestIdentifier, IEC_KEYWORDS, DefaultType @@ -140,10 +140,10 @@ if colname == "Initial Value": colname = "InitialValue" value = getattr(self.data[row], colname, "") - if colname == "Type" and isinstance(value, TupleType): + if colname == "Type" and isinstance(value, tuple): if value[0] == "array": return "ARRAY [%s] OF %s" % (",".join(map("..".join, value[2])), value[1]) - if not isinstance(value, (StringType, UnicodeType)): + if not isinstance(value, string_types): value = str(value) if colname in ["Class", "Option"]: return _(value) @@ -280,7 +280,7 @@ except Exception: message = _("Invalid value \"%s\" for variable grid element") % data values = None - if not isinstance(values, TupleType): + if not isinstance(values, tuple): message = _("Invalid value \"%s\" for variable grid element") % data values = None if values is not None: @@ -700,7 +700,7 @@ return self.TagName def IsFunctionBlockType(self, name): - if isinstance(name, TupleType) or \ + if isinstance(name, tuple) or \ self.ElementType != "function" and self.BodyType in ["ST", "IL"]: return False else: @@ -988,7 +988,7 @@ event.Skip() def AddVariableHighlight(self, infos, highlight_type): - if isinstance(infos[0], TupleType): + if isinstance(infos[0], tuple): for i in xrange(*infos[0]): self.Table.AddHighlight((i,) + infos[1:], highlight_type) cell_visible = infos[0][0] @@ -1000,7 +1000,7 @@ self.RefreshHighlightsTimer.Start(int(REFRESH_HIGHLIGHT_PERIOD * 1000), oneShot=True) def RemoveVariableHighlight(self, infos, highlight_type): - if isinstance(infos[0], TupleType): + if isinstance(infos[0], tuple): for i in xrange(*infos[0]): self.Table.RemoveHighlight((i,) + infos[1:], highlight_type) else: diff -r b0560adec4b7 -r 5024c19ca8f0 dialogs/ArrayTypeDialog.py --- a/dialogs/ArrayTypeDialog.py Thu Oct 11 10:25:19 2018 +0300 +++ b/dialogs/ArrayTypeDialog.py Thu Oct 11 12:00:40 2018 +0300 @@ -24,7 +24,6 @@ from __future__ import absolute_import import re -from types import TupleType import wx @@ -83,7 +82,7 @@ for datatype in datatypes: self.BaseType.Append(datatype) - if isinstance(infos, TupleType) and infos[0] == "array": + if isinstance(infos, tuple) and infos[0] == "array": self.BaseType.SetStringSelection(infos[1]) self.Dimensions.SetStrings(map("..".join, infos[2])) elif infos in datatypes: diff -r b0560adec4b7 -r 5024c19ca8f0 editors/ConfTreeNodeEditor.py --- a/editors/ConfTreeNodeEditor.py Thu Oct 11 10:25:19 2018 +0300 +++ b/editors/ConfTreeNodeEditor.py Thu Oct 11 12:00:40 2018 +0300 @@ -26,7 +26,6 @@ from __future__ import absolute_import from __future__ import division -import types import wx @@ -403,8 +402,8 @@ boxsizer.AddWindow(statictext, border=5, flag=wx.ALIGN_CENTER_VERTICAL | wx.RIGHT) - if isinstance(element_infos["type"], types.ListType): - if isinstance(element_infos["value"], types.TupleType): + if isinstance(element_infos["type"], list): + if isinstance(element_infos["value"], tuple): browse_boxsizer = wx.BoxSizer(wx.HORIZONTAL) boxsizer.AddSizer(browse_boxsizer) @@ -430,7 +429,7 @@ if element_infos["use"] == "optional": combobox.Append("") - if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], types.TupleType): + if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], tuple): for choice, _xsdclass in element_infos["type"]: combobox.Append(choice) name = element_infos["name"] @@ -453,7 +452,7 @@ combobox.SetStringSelection(element_infos["value"]) combobox.Bind(wx.EVT_COMBOBOX, callback, combobox) - elif isinstance(element_infos["type"], types.DictType): + elif isinstance(element_infos["type"], dict): scmin = -(2**31) scmax = 2**31-1 if "min" in element_infos["type"]: diff -r b0560adec4b7 -r 5024c19ca8f0 editors/DataTypeEditor.py --- a/editors/DataTypeEditor.py Thu Oct 11 10:25:19 2018 +0300 +++ b/editors/DataTypeEditor.py Thu Oct 11 12:00:40 2018 +0300 @@ -26,7 +26,6 @@ from __future__ import absolute_import import re -from types import TupleType from six.moves import xrange import wx @@ -83,7 +82,7 @@ colname = self.GetColLabelValue(col, False) value = self.data[row].get(colname, "") - if colname == "Type" and isinstance(value, TupleType): + if colname == "Type" and isinstance(value, tuple): if value[0] == "array": return "ARRAY [%s] OF %s" % (",".join(map("..".join, value[2])), value[1]) return value diff -r b0560adec4b7 -r 5024c19ca8f0 editors/LDViewer.py --- a/editors/LDViewer.py Thu Oct 11 10:25:19 2018 +0300 +++ b/editors/LDViewer.py Thu Oct 11 12:00:40 2018 +0300 @@ -25,7 +25,6 @@ from __future__ import absolute_import from __future__ import division -from types import * import wx from six.moves import xrange diff -r b0560adec4b7 -r 5024c19ca8f0 editors/SFCViewer.py --- a/editors/SFCViewer.py Thu Oct 11 10:25:19 2018 +0300 +++ b/editors/SFCViewer.py Thu Oct 11 12:00:40 2018 +0300 @@ -25,7 +25,6 @@ from __future__ import absolute_import from __future__ import division -from types import * import wx diff -r b0560adec4b7 -r 5024c19ca8f0 editors/TextViewer.py --- a/editors/TextViewer.py Thu Oct 11 10:25:19 2018 +0300 +++ b/editors/TextViewer.py Thu Oct 11 12:00:40 2018 +0300 @@ -26,7 +26,6 @@ from __future__ import absolute_import from __future__ import division import re -from types import * import wx import wx.stc diff -r b0560adec4b7 -r 5024c19ca8f0 editors/Viewer.py --- a/editors/Viewer.py Thu Oct 11 10:25:19 2018 +0300 +++ b/editors/Viewer.py Thu Oct 11 12:00:40 2018 +0300 @@ -27,7 +27,6 @@ from __future__ import division import math from time import time as gettime -from types import TupleType from threading import Lock import wx @@ -277,7 +276,7 @@ except Exception: message = _("Invalid value \"%s\" for viewer block") % data values = None - if not isinstance(values, TupleType): + if not isinstance(values, tuple): message = _("Invalid value \"%s\" for viewer block") % data values = None if values is not None: @@ -3454,7 +3453,7 @@ middle = True new_pos = [bbx.x, bbx.y] result = self.Controler.PasteEditedElementInstances(self.TagName, element, new_pos, middle, self.Debug) - if not isinstance(result, (StringType, UnicodeType)): + if not isinstance(result, string_types): self.RefreshBuffer() self.RefreshView(selection=result) self.RefreshVariablePanel() diff -r b0560adec4b7 -r 5024c19ca8f0 etherlab/ConfigEditor.py --- a/etherlab/ConfigEditor.py Thu Oct 11 10:25:19 2018 +0300 +++ b/etherlab/ConfigEditor.py Thu Oct 11 12:00:40 2018 +0300 @@ -13,7 +13,6 @@ from __future__ import division import os import re -from types import TupleType import wx import wx.grid @@ -418,7 +417,7 @@ except Exception: message = _("Invalid value \"%s\" for process variable") % data values = None - if not isinstance(values, TupleType): + if not isinstance(values, tuple): message = _("Invalid value \"%s\" for process variable") % data values = None if values is not None and col != wx.NOT_FOUND and row != wx.NOT_FOUND and 2 <= col <= 3: @@ -480,7 +479,7 @@ except Exception: message = _("Invalid value \"%s\" for startup command") % data values = None - if not isinstance(values, TupleType): + if not isinstance(values, tuple): message = _("Invalid value \"%s\" for startup command") % data values = None if values is not None: diff -r b0560adec4b7 -r 5024c19ca8f0 graphics/GraphicCommons.py --- a/graphics/GraphicCommons.py Thu Oct 11 10:25:19 2018 +0300 +++ b/graphics/GraphicCommons.py Thu Oct 11 12:00:40 2018 +0300 @@ -26,7 +26,7 @@ from __future__ import absolute_import from __future__ import division from math import * -from types import * +from six import string_types from six.moves import xrange import wx @@ -1081,7 +1081,7 @@ y -= 5 height += 5 rect = wx.Rect(x - abs(movex), y - abs(movey), width + 2 * abs(movex), height + 2 * abs(movey)) - if self.ValueSize is None and isinstance(self.ComputedValue, (StringType, UnicodeType)): + if self.ValueSize is None and isinstance(self.ComputedValue, string_types): self.ValueSize = self.ParentBlock.Parent.GetMiniTextExtent(self.ComputedValue) if self.ValueSize is not None: width, height = self.ValueSize @@ -1163,7 +1163,7 @@ self.Parent.ElementNeedRefresh(self) def GetComputedValue(self): - if self.Value is not None and self.Value != "undefined" and not isinstance(self.Value, BooleanType): + if self.Value is not None and self.Value != "undefined" and not isinstance(self.Value, bool): return self.Value return None @@ -1200,7 +1200,7 @@ current = False for wire, _handle in self.Wires: value = wire.GetValue() - if current != "undefined" and isinstance(value, BooleanType): + if current != "undefined" and isinstance(value, bool): current |= wire.GetValue() elif value == "undefined": current = "undefined" @@ -1472,7 +1472,7 @@ else: if not self.Valid: dc.SetPen(MiterPen(wx.RED)) - elif isinstance(self.Value, BooleanType) and self.Value: + elif isinstance(self.Value, bool) and self.Value: if self.Forced: dc.SetPen(MiterPen(wx.CYAN)) else: @@ -1536,10 +1536,10 @@ if not getattr(dc, "printing", False): DrawHighlightedText(dc, self.Name, self.Highlights, xtext, ytext) - if self.Value is not None and not isinstance(self.Value, BooleanType) and self.Value != "undefined": + if self.Value is not None and not isinstance(self.Value, bool) and self.Value != "undefined": dc.SetFont(self.ParentBlock.Parent.GetMiniFont()) dc.SetTextForeground(wx.NamedColour("purple")) - if self.ValueSize is None and isinstance(self.ComputedValue, (StringType, UnicodeType)): + if self.ValueSize is None and isinstance(self.ComputedValue, string_types): self.ValueSize = self.ParentBlock.Parent.GetMiniTextExtent(self.ComputedValue) if self.ValueSize is not None: width, height = self.ValueSize @@ -1607,7 +1607,7 @@ rect = rect.Union(self.StartConnected.GetRedrawRect(movex, movey)) if self.EndConnected: rect = rect.Union(self.EndConnected.GetRedrawRect(movex, movey)) - if self.ValueSize is None and isinstance(self.ComputedValue, (StringType, UnicodeType)): + if self.ValueSize is None and isinstance(self.ComputedValue, string_types): self.ValueSize = self.Parent.GetMiniTextExtent(self.ComputedValue) if self.ValueSize is not None: width, height = self.ValueSize @@ -1756,7 +1756,7 @@ self.Parent.ElementNeedRefresh(self) def GetComputedValue(self): - if self.Value is not None and self.Value != "undefined" and not isinstance(self.Value, BooleanType): + if self.Value is not None and self.Value != "undefined" and not isinstance(self.Value, bool): return self.Value return None @@ -1788,7 +1788,7 @@ self.EndConnected.RefreshValue() if self.Visible: self.Parent.ElementNeedRefresh(self) - if isinstance(value, BooleanType) and self.StartConnected is not None: + if isinstance(value, bool) and self.StartConnected is not None: block = self.StartConnected.GetParentBlock() block.SpreadCurrent() @@ -2681,7 +2681,7 @@ if not self.Valid: dc.SetPen(MiterPen(wx.RED)) dc.SetBrush(wx.RED_BRUSH) - elif isinstance(self.Value, BooleanType) and self.Value: + elif isinstance(self.Value, bool) and self.Value: if self.Forced: dc.SetPen(MiterPen(wx.CYAN)) dc.SetBrush(wx.CYAN_BRUSH) @@ -2719,10 +2719,10 @@ end = 1 dc.DrawLine(self.Points[self.SelectedSegment].x - 1, self.Points[self.SelectedSegment].y, self.Points[self.SelectedSegment + 1].x + end, self.Points[self.SelectedSegment + 1].y) - if self.Value is not None and not isinstance(self.Value, BooleanType) and self.Value != "undefined": + if self.Value is not None and not isinstance(self.Value, bool) and self.Value != "undefined": dc.SetFont(self.Parent.GetMiniFont()) dc.SetTextForeground(wx.NamedColour("purple")) - if self.ValueSize is None and isinstance(self.ComputedValue, (StringType, UnicodeType)): + if self.ValueSize is None and isinstance(self.ComputedValue, string_types): self.ValueSize = self.Parent.GetMiniTextExtent(self.ComputedValue) if self.ValueSize is not None: width, height = self.ValueSize diff -r b0560adec4b7 -r 5024c19ca8f0 plcopen/plcopen.py --- a/plcopen/plcopen.py Thu Oct 11 10:25:19 2018 +0300 +++ b/plcopen/plcopen.py Thu Oct 11 12:00:40 2018 +0300 @@ -26,7 +26,6 @@ from __future__ import absolute_import from __future__ import division -from types import * import re from collections import OrderedDict diff -r b0560adec4b7 -r 5024c19ca8f0 svgui/pyjs/pyjs.py --- a/svgui/pyjs/pyjs.py Thu Oct 11 10:25:19 2018 +0300 +++ b/svgui/pyjs/pyjs.py Thu Oct 11 12:00:40 2018 +0300 @@ -17,7 +17,6 @@ from __future__ import print_function import sys -from types import StringType import compiler from compiler import ast import os @@ -1388,7 +1387,7 @@ return self.expr(node.left, current_klass) + " * " + self.expr(node.right, current_klass) def _mod(self, node, current_klass): - if isinstance(node.left, ast.Const) and isinstance(node.left.value, StringType): + if isinstance(node.left, ast.Const) and isinstance(node.left.value, str): self.imported_js.add("sprintf.js") # Include the sprintf functionality if it is used return "sprintf("+self.expr(node.left, current_klass) + ", " + self.expr(node.right, current_klass)+")" return self.expr(node.left, current_klass) + " % " + self.expr(node.right, current_klass) diff -r b0560adec4b7 -r 5024c19ca8f0 tests/tools/check_source.sh --- a/tests/tools/check_source.sh Thu Oct 11 10:25:19 2018 +0300 +++ b/tests/tools/check_source.sh Thu Oct 11 12:00:40 2018 +0300 @@ -369,6 +369,7 @@ enable=$enable,W1645 # (exception-message-attribute) Exception.message removed in Python 3 enable=$enable,W1649 # (deprecated-string-function) Accessing a deprecated function on the string module enable=$enable,W1651 # (deprecated-itertools-function) Accessing a deprecated function on the itertools module + enable=$enable,W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module # enable= options= diff -r b0560adec4b7 -r 5024c19ca8f0 xmlclass/xmlclass.py --- a/xmlclass/xmlclass.py Thu Oct 11 10:25:19 2018 +0300 +++ b/xmlclass/xmlclass.py Thu Oct 11 12:00:40 2018 +0300 @@ -28,12 +28,12 @@ import os import re import datetime -from types import * from xml.dom import minidom from xml.sax.saxutils import unescape from collections import OrderedDict from builtins import str as text +from six import string_types from six.moves import xrange from lxml import etree @@ -575,7 +575,7 @@ "extract": ExtractAny, "generate": GenerateAny, "initial": InitialAny, - "check": lambda x: isinstance(x, (StringType, UnicodeType, etree.ElementBase)) + "check": lambda x: isinstance(x, (string_types, etree.ElementBase)) } @@ -607,7 +607,7 @@ def FindTypeInfos(factory, infos): - if isinstance(infos, (UnicodeType, StringType)): + if isinstance(infos, string_types): namespace, name = DecomposeQualifiedName(infos) return factory.GetQualifiedNameInfos(name, namespace) return infos @@ -953,7 +953,7 @@ if parent is not None else None) parent_class = lookup_classes.get(parent) if parent_class is not None: - if isinstance(parent_class, ListType): + if isinstance(parent_class, list): if typeinfos not in parent_class: lookup_classes[parent].append(typeinfos) elif parent_class != typeinfos: @@ -963,13 +963,13 @@ def AddToLookupClass(self, name, parent, typeinfos): lookup_name = self.etreeNamespaceFormat % name - if isinstance(typeinfos, (StringType, UnicodeType)): + if isinstance(typeinfos, string_types): self.AddEquivalentClass(name, typeinfos) typeinfos = self.etreeNamespaceFormat % typeinfos lookup_classes = self.ComputedClassesLookUp.get(lookup_name) if lookup_classes is None: self.ComputedClassesLookUp[lookup_name] = (typeinfos, parent) - elif isinstance(lookup_classes, DictType): + elif isinstance(lookup_classes, dict): self.AddDistinctionBetweenParentsInLookupClass( lookup_classes, parent, typeinfos) else: @@ -981,7 +981,7 @@ self.ComputedClassesLookUp[lookup_name] = lookup_classes def ExtractTypeInfos(self, name, parent, typeinfos): - if isinstance(typeinfos, (StringType, UnicodeType)): + if isinstance(typeinfos, string_types): namespace, type_name = DecomposeQualifiedName(typeinfos) infos = self.GetQualifiedNameInfos(type_name, namespace) if name != "base": @@ -992,13 +992,13 @@ if infos["type"] == COMPLEXTYPE: type_name, parent = self.SplitQualifiedName(type_name, namespace) result = self.CreateClass(type_name, parent, infos) - if result is not None and not isinstance(result, (UnicodeType, StringType)): + if result is not None and not isinstance(result, string_types): self.Namespaces[self.TargetNamespace][result["name"]] = result return result elif infos["type"] == ELEMENT and infos["elmt_type"]["type"] == COMPLEXTYPE: type_name, parent = self.SplitQualifiedName(type_name, namespace) result = self.CreateClass(type_name, parent, infos["elmt_type"]) - if result is not None and not isinstance(result, (UnicodeType, StringType)): + if result is not None and not isinstance(result, string_types): self.Namespaces[self.TargetNamespace][result["name"]] = result return result else: @@ -1020,19 +1020,19 @@ self.ParseSchema() for name, infos in self.Namespaces[self.TargetNamespace].items(): if infos["type"] == ELEMENT: - if not isinstance(infos["elmt_type"], (UnicodeType, StringType)) and \ + if not isinstance(infos["elmt_type"], string_types) and \ infos["elmt_type"]["type"] == COMPLEXTYPE: self.ComputeAfter.append((name, None, infos["elmt_type"], True)) while len(self.ComputeAfter) > 0: result = self.CreateClass(*self.ComputeAfter.pop(0)) - if result is not None and not isinstance(result, (UnicodeType, StringType)): + if result is not None and not isinstance(result, string_types): self.Namespaces[self.TargetNamespace][result["name"]] = result elif infos["type"] == COMPLEXTYPE: self.ComputeAfter.append((name, None, infos)) while len(self.ComputeAfter) > 0: result = self.CreateClass(*self.ComputeAfter.pop(0)) if result is not None and \ - not isinstance(result, (UnicodeType, StringType)): + not isinstance(result, string_types): self.Namespaces[self.TargetNamespace][result["name"]] = result elif infos["type"] == ELEMENTSGROUP: elements = [] @@ -1041,17 +1041,17 @@ elif "choices" in infos: elements = infos["choices"] for element in elements: - if not isinstance(element["elmt_type"], (UnicodeType, StringType)) and \ + if not isinstance(element["elmt_type"], string_types) and \ element["elmt_type"]["type"] == COMPLEXTYPE: self.ComputeAfter.append((element["name"], infos["name"], element["elmt_type"])) while len(self.ComputeAfter) > 0: result = self.CreateClass(*self.ComputeAfter.pop(0)) if result is not None and \ - not isinstance(result, (UnicodeType, StringType)): + not isinstance(result, string_types): self.Namespaces[self.TargetNamespace][result["name"]] = result for name, parents in self.ComputedClassesLookUp.iteritems(): - if isinstance(parents, DictType): + if isinstance(parents, dict): computed_classes = parents.items() elif parents[1] is not None: computed_classes = [(self.etreeNamespaceFormat % parents[1], parents[0])] @@ -1059,7 +1059,7 @@ computed_classes = [] for parent, computed_class in computed_classes: for equivalent_parent in self.GetEquivalentParents(parent): - if not isinstance(parents, DictType): + if not isinstance(parents, dict): parents = dict(computed_classes) self.ComputedClassesLookUp[name] = parents parents[equivalent_parent] = computed_class @@ -1382,7 +1382,7 @@ else: insertion_point = 0 - if not isinstance(value, ListType): + if not isinstance(value, list): value = [value] for element in reversed(value): @@ -1748,13 +1748,13 @@ def GetElementClass(self, element_tag, parent_tag=None, default=DefaultElementClass): element_class = self.LookUpClasses.get(element_tag, (default, None)) - if not isinstance(element_class, DictType): - if isinstance(element_class[0], (StringType, UnicodeType)): + if not isinstance(element_class, dict): + if isinstance(element_class[0], string_types): return self.GetElementClass(element_class[0], default=default) return element_class[0] element_with_parent_class = element_class.get(parent_tag, default) - if isinstance(element_with_parent_class, (StringType, UnicodeType)): + if isinstance(element_with_parent_class, string_types): return self.GetElementClass(element_with_parent_class, default=default) return element_with_parent_class @@ -1811,12 +1811,12 @@ parent = element.getparent() element_class = self.GetElementClass( element.tag, parent.tag if parent is not None else None) - if isinstance(element_class, ListType): + if isinstance(element_class, list): children = "".join([ "%s " % etree.QName(child.tag).localname for child in element]) for possible_class in element_class: - if isinstance(possible_class, (StringType, UnicodeType)): + if isinstance(possible_class, string_types): possible_class = self.GetElementClass(possible_class) if possible_class.StructurePattern.match(children) is not None: return possible_class @@ -1890,7 +1890,7 @@ (subclass of lxml.etree._Element created by class factory) """ element_class = self.GetElementClass(element_tag, parent_tag) - if isinstance(element_class, ListType): + if isinstance(element_class, list): if class_idx is not None and class_idx < len(element_class): element_class = element_class[class_idx] else: diff -r b0560adec4b7 -r 5024c19ca8f0 xmlclass/xsdschema.py --- a/xmlclass/xsdschema.py Thu Oct 11 10:25:19 2018 +0300 +++ b/xmlclass/xsdschema.py Thu Oct 11 12:00:40 2018 +0300 @@ -28,8 +28,10 @@ import os import re import datetime +from types import FunctionType from xml.dom import minidom -from types import * +from six import string_types +from past.builtins import long from xmlclass.xmlclass import * @@ -61,7 +63,7 @@ if name is not None: ind1, _ind2 = getIndent(indent, name) text += ind1 + "<%s>" % name - if isinstance(value, IntType): + if isinstance(value, int): text += str(value) elif value in extra_values or value % 1 != 0: text += float_format(value) @@ -167,7 +169,7 @@ if typeinfos["type"] in ["restriction", "extension"]: # Search for base type definition - if isinstance(typeinfos["base"], (StringType, UnicodeType)): + if isinstance(typeinfos["base"], string_types): basetypeinfos = factory.FindSchemaElement(typeinfos["base"], SIMPLETYPE) if basetypeinfos is None: raise "\"%s\" isn't defined!" % typeinfos["base"] @@ -391,7 +393,7 @@ elif typeinfos["type"] == "list": # Search for item type definition - if isinstance(typeinfos["itemType"], (StringType, UnicodeType)): + if isinstance(typeinfos["itemType"], string_types): itemtypeinfos = factory.FindSchemaElement(typeinfos["itemType"], SIMPLETYPE) if itemtypeinfos is None: raise "\"%s\" isn't defined!" % typeinfos["itemType"] @@ -437,7 +439,7 @@ # Search for member types definition membertypesinfos = [] for membertype in typeinfos["memberTypes"]: - if isinstance(membertype, (StringType, UnicodeType)): + if isinstance(membertype, string_types): infos = factory.FindSchemaElement(membertype, SIMPLETYPE) if infos is None: raise ValueError("\"%s\" isn't defined!" % membertype) @@ -478,7 +480,7 @@ SimpleTypeInitialValue = membertypesinfos[0]["initial"] def GenerateSimpleTypeFunction(value): - if isinstance(value, BooleanType): + if isinstance(value, bool): return {True: "true", False: "false"}[value] else: return str(value) @@ -511,7 +513,7 @@ attrnames = {} if base is not None: basetypeinfos = factory.FindSchemaElement(base) - if not isinstance(basetypeinfos, (UnicodeType, StringType)) and basetypeinfos["type"] == COMPLEXTYPE: + if not isinstance(basetypeinfos, string_types) and basetypeinfos["type"] == COMPLEXTYPE: attrnames = dict(map(lambda x: (x["name"], True), basetypeinfos["attributes"])) for element in elements: @@ -812,7 +814,7 @@ raise ValueError("Only group composed of \"choice\" can be referenced in \"choice\" element!") choices_tmp = [] for choice in elmtgroup["choices"]: - if not isinstance(choice["elmt_type"], (UnicodeType, StringType)) and choice["elmt_type"]["type"] == COMPLEXTYPE: + if not isinstance(choice["elmt_type"], string_types) and choice["elmt_type"]["type"] == COMPLEXTYPE: elmt_type = "%s_%s" % (elmtgroup["name"], choice["name"]) if factory.TargetNamespace is not None: elmt_type = "%s:%s" % (factory.TargetNamespace, elmt_type) @@ -846,7 +848,7 @@ raise ValueError("Only group composed of \"sequence\" can be referenced in \"sequence\" element!") elements_tmp = [] for element in elmtgroup["elements"]: - if not isinstance(element["elmt_type"], (UnicodeType, StringType)) and element["elmt_type"]["type"] == COMPLEXTYPE: + if not isinstance(element["elmt_type"], string_types) and element["elmt_type"]["type"] == COMPLEXTYPE: elmt_type = "%s_%s" % (elmtgroup["name"], element["name"]) if factory.TargetNamespace is not None: elmt_type = "%s:%s" % (factory.TargetNamespace, elmt_type) @@ -982,16 +984,16 @@ def CompareSchema(schema, reference): - if isinstance(schema, ListType): - if not isinstance(reference, ListType) or len(schema) != len(reference): + if isinstance(schema, list): + if not isinstance(reference, list) or len(schema) != len(reference): return False for i, value in enumerate(schema): result = CompareSchema(value, reference[i]) if not result: return result return True - elif isinstance(schema, DictType): - if not isinstance(reference, DictType) or len(schema) != len(reference): + elif isinstance(schema, dict): + if not isinstance(reference, dict) or len(schema) != len(reference): return False for name, value in schema.items(): ref_value = reference.get(name, None) @@ -2212,8 +2214,7 @@ "facets": STRING_FACETS, "generate": GenerateSimpleTypeXMLText(lambda x: x), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) - }, + "check": lambda x: isinstance(x, string_types)}, "normalizedString": { "type": SIMPLETYPE, @@ -2222,7 +2223,7 @@ "facets": STRING_FACETS, "generate": GenerateSimpleTypeXMLText(lambda x: x), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "token": { @@ -2232,7 +2233,7 @@ "facets": STRING_FACETS, "generate": GenerateSimpleTypeXMLText(lambda x: x), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "base64Binary": { @@ -2242,7 +2243,7 @@ "facets": STRING_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: 0, - "check": lambda x: isinstance(x, (IntType, LongType)) + "check": lambda x: isinstance(x, (int, long)) }, "hexBinary": { @@ -2252,7 +2253,7 @@ "facets": STRING_FACETS, "generate": GenerateSimpleTypeXMLText(lambda x: ("%."+str(int(round(len("%X" % x)/2.)*2))+"X") % x), "initial": lambda: 0, - "check": lambda x: isinstance(x, (IntType, LongType)) + "check": lambda x: isinstance(x, (int, long)) }, "integer": { @@ -2262,7 +2263,7 @@ "facets": DECIMAL_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: 0, - "check": lambda x: isinstance(x, IntType) + "check": lambda x: isinstance(x, int) }, "positiveInteger": { @@ -2272,7 +2273,7 @@ "facets": DECIMAL_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: 1, - "check": lambda x: isinstance(x, IntType) + "check": lambda x: isinstance(x, int) }, "negativeInteger": { @@ -2282,7 +2283,7 @@ "facets": DECIMAL_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: -1, - "check": lambda x: isinstance(x, IntType) + "check": lambda x: isinstance(x, int) }, "nonNegativeInteger": { @@ -2292,7 +2293,7 @@ "facets": DECIMAL_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: 0, - "check": lambda x: isinstance(x, IntType) + "check": lambda x: isinstance(x, int) }, "nonPositiveInteger": { @@ -2302,7 +2303,7 @@ "facets": DECIMAL_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: 0, - "check": lambda x: isinstance(x, IntType) + "check": lambda x: isinstance(x, int) }, "long": { @@ -2312,7 +2313,7 @@ "facets": DECIMAL_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: 0, - "check": lambda x: isinstance(x, IntType) + "check": lambda x: isinstance(x, int) }, "unsignedLong": { @@ -2322,7 +2323,7 @@ "facets": DECIMAL_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: 0, - "check": lambda x: isinstance(x, IntType) + "check": lambda x: isinstance(x, int) }, "int": { @@ -2332,7 +2333,7 @@ "facets": DECIMAL_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: 0, - "check": lambda x: isinstance(x, IntType) + "check": lambda x: isinstance(x, int) }, "unsignedInt": { @@ -2342,7 +2343,7 @@ "facets": DECIMAL_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: 0, - "check": lambda x: isinstance(x, IntType) + "check": lambda x: isinstance(x, int) }, "short": { @@ -2352,7 +2353,7 @@ "facets": DECIMAL_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: 0, - "check": lambda x: isinstance(x, IntType) + "check": lambda x: isinstance(x, int) }, "unsignedShort": { @@ -2362,7 +2363,7 @@ "facets": DECIMAL_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: 0, - "check": lambda x: isinstance(x, IntType) + "check": lambda x: isinstance(x, int) }, "byte": { @@ -2372,7 +2373,7 @@ "facets": DECIMAL_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: 0, - "check": lambda x: isinstance(x, IntType) + "check": lambda x: isinstance(x, int) }, "unsignedByte": { @@ -2382,7 +2383,7 @@ "facets": DECIMAL_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: 0, - "check": lambda x: isinstance(x, IntType) + "check": lambda x: isinstance(x, int) }, "decimal": { @@ -2392,7 +2393,7 @@ "facets": DECIMAL_FACETS, "generate": GenerateFloatXMLText(decimal=3), "initial": lambda: 0., - "check": lambda x: isinstance(x, (IntType, FloatType)) + "check": lambda x: isinstance(x, (int, float)) }, "float": { @@ -2402,7 +2403,7 @@ "facets": NUMBER_FACETS, "generate": GenerateFloatXMLText(["INF", "-INF", "NaN"]), "initial": lambda: 0., - "check": lambda x: {"INF": True, "-INF": True, "NaN": True}.get(x, isinstance(x, (IntType, FloatType))) + "check": lambda x: {"INF": True, "-INF": True, "NaN": True}.get(x, isinstance(x, (int, float))) }, "double": { @@ -2412,7 +2413,7 @@ "facets": NUMBER_FACETS, "generate": GenerateFloatXMLText(["INF", "-INF", "NaN"]), "initial": lambda: 0., - "check": lambda x: {"INF": True, "-INF": True, "NaN": True}.get(x, isinstance(x, (IntType, FloatType))) + "check": lambda x: {"INF": True, "-INF": True, "NaN": True}.get(x, isinstance(x, (int, float))) }, "boolean": { @@ -2422,7 +2423,7 @@ "facets": GenerateDictFacets(["pattern", "whiteSpace"]), "generate": GenerateSimpleTypeXMLText(lambda x: {True: "true", False: "false"}[x]), "initial": lambda: False, - "check": lambda x: isinstance(x, BooleanType) + "check": lambda x: isinstance(x, bool) }, "duration": { @@ -2432,7 +2433,7 @@ "facets": NUMBER_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "dateTime": { @@ -2472,7 +2473,7 @@ "facets": NUMBER_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "gYearMonth": { @@ -2482,7 +2483,7 @@ "facets": NUMBER_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "gMonth": { @@ -2492,7 +2493,7 @@ "facets": NUMBER_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "gMonthDay": { @@ -2502,7 +2503,7 @@ "facets": NUMBER_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "gDay": { @@ -2512,7 +2513,7 @@ "facets": NUMBER_FACETS, "generate": GenerateSimpleTypeXMLText(str), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "Name": { @@ -2522,7 +2523,7 @@ "facets": STRING_FACETS, "generate": GenerateSimpleTypeXMLText(lambda x: x), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "QName": { @@ -2532,7 +2533,7 @@ "facets": STRING_FACETS, "generate": GenerateSimpleTypeXMLText(lambda x: x), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "NCName": { @@ -2542,7 +2543,7 @@ "facets": STRING_FACETS, "generate": GenerateSimpleTypeXMLText(lambda x: x), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "anyURI": { @@ -2552,7 +2553,7 @@ "facets": STRING_FACETS, "generate": GenerateSimpleTypeXMLText(lambda x: x), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "language": { @@ -2562,7 +2563,7 @@ "facets": STRING_FACETS, "generate": GenerateSimpleTypeXMLText(lambda x: x), "initial": lambda: "en", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "ID": { @@ -2572,7 +2573,7 @@ "facets": STRING_FACETS, "generate": GenerateSimpleTypeXMLText(lambda x: x), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "IDREF": { @@ -2582,7 +2583,7 @@ "facets": STRING_FACETS, "generate": GenerateSimpleTypeXMLText(lambda x: x), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "IDREFS": { @@ -2592,7 +2593,7 @@ "facets": STRING_FACETS, "generate": GenerateSimpleTypeXMLText(lambda x: x), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "ENTITY": { @@ -2602,7 +2603,7 @@ "facets": STRING_FACETS, "generate": GenerateSimpleTypeXMLText(lambda x: x), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "ENTITIES": { @@ -2612,7 +2613,7 @@ "facets": STRING_FACETS, "generate": GenerateSimpleTypeXMLText(lambda x: x), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "NOTATION": { @@ -2622,7 +2623,7 @@ "facets": STRING_FACETS, "generate": GenerateSimpleTypeXMLText(lambda x: x), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "NMTOKEN": { @@ -2632,7 +2633,7 @@ "facets": STRING_FACETS, "generate": GenerateSimpleTypeXMLText(lambda x: x), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, "NMTOKENS": { @@ -2642,7 +2643,7 @@ "facets": STRING_FACETS, "generate": GenerateSimpleTypeXMLText(lambda x: x), "initial": lambda: "", - "check": lambda x: isinstance(x, (StringType, UnicodeType)) + "check": lambda x: isinstance(x, string_types) }, # Complex Types