@@ -84,7 +84,7 @@ class Release(Command): | |||||
try: | try: | ||||
from urllib.request import urlopen | from urllib.request import urlopen | ||||
except ImportError: | except ImportError: | ||||
from urllib2 import urlopen | |||||
from urllib.request import urlopen | |||||
response = urlopen( | response = urlopen( | ||||
"http://pypi.python.org/pypi/%s/json" % NAME) | "http://pypi.python.org/pypi/%s/json" % NAME) | ||||
data = json.load(codecs.getreader("utf-8")(response)) | data = json.load(codecs.getreader("utf-8")(response)) | ||||
@@ -114,7 +114,7 @@ class PreRelease(Command): | |||||
try: | try: | ||||
from urllib.request import urlopen | from urllib.request import urlopen | ||||
except ImportError: | except ImportError: | ||||
from urllib2 import urlopen | |||||
from urllib.request import urlopen | |||||
response = urlopen( | response = urlopen( | ||||
"http://pypi.python.org/pypi/%s/json" % NAME) | "http://pypi.python.org/pypi/%s/json" % NAME) | ||||
data = json.load(codecs.getreader("utf-8")(response)) | data = json.load(codecs.getreader("utf-8")(response)) | ||||
@@ -50,7 +50,7 @@ class WSDLToolsTestCase(unittest.TestCase): | |||||
if hasattr(nameGenerator, '__next__'): | if hasattr(nameGenerator, '__next__'): | ||||
self.path = nameGenerator.__next__() | self.path = nameGenerator.__next__() | ||||
else: | else: | ||||
self.path = nameGenerator.next() | |||||
self.path = next(nameGenerator) | |||||
# print(self.path) | # print(self.path) | ||||
sys.stdout.flush() | sys.stdout.flush() | ||||
@@ -70,7 +70,7 @@ class WSDLToolsTestCase(unittest.TestCase): | |||||
for node in DOM.getElements(definition, tag_name, nspname): | for node in DOM.getElements(definition, tag_name, nspname): | ||||
name = DOM.getAttr(node, key) | name = DOM.getAttr(node, key) | ||||
comp = component[name] # noqa F841 | comp = component[name] # noqa F841 | ||||
self.failUnlessEqual(eval('comp.%s' % key), name) | |||||
self.assertEqual(eval('comp.%s' % key), name) | |||||
def checkXSDCollection(self, tag_name, component, node, key='name'): | def checkXSDCollection(self, tag_name, component, node, key='name'): | ||||
for cnode in DOM.getElements(node, tag_name): | for cnode in DOM.getElements(node, tag_name): | ||||
@@ -124,9 +124,9 @@ class WSDLToolsTestCase(unittest.TestCase): | |||||
raise | raise | ||||
try: | try: | ||||
for key in self.wsdl.types.keys(): | |||||
for key in list(self.wsdl.types.keys()): | |||||
schema = self.wsdl.types[key] | schema = self.wsdl.types[key] | ||||
self.failUnlessEqual(key, schema.getTargetNamespace()) | |||||
self.assertEqual(key, schema.getTargetNamespace()) | |||||
definition = self.wsdl.document.documentElement | definition = self.wsdl.document.documentElement | ||||
version = DOM.WSDLUriToVersion(definition.namespaceURI) | version = DOM.WSDLUriToVersion(definition.namespaceURI) | ||||
@@ -144,9 +144,9 @@ class WSDLToolsTestCase(unittest.TestCase): | |||||
raise | raise | ||||
if self.wsdl.extensions: | if self.wsdl.extensions: | ||||
print('No check for WSDLTools(%s) Extensions:' % (self.wsdl.name)) | |||||
print(('No check for WSDLTools(%s) Extensions:' % (self.wsdl.name))) | |||||
for ext in self.wsdl.extensions: | for ext in self.wsdl.extensions: | ||||
print('\t', ext) | |||||
print(('\t', ext)) | |||||
def schemaAttributesDeclarations(self, schema, node): | def schemaAttributesDeclarations(self, schema, node): | ||||
self.checkXSDCollection('attribute', schema.attr_decl, node) | self.checkXSDCollection('attribute', schema.attr_decl, node) | ||||
@@ -170,7 +170,7 @@ def setUpOptions(section): | |||||
print('fatal error: configuration file config.txt not present') | print('fatal error: configuration file config.txt not present') | ||||
sys.exit(0) | sys.exit(0) | ||||
if not cp.has_section(section): | if not cp.has_section(section): | ||||
print('%s section not present in configuration file, exiting' % section) | |||||
print(('%s section not present in configuration file, exiting' % section)) | |||||
sys.exit(0) | sys.exit(0) | ||||
return cp, len(cp.options(section)) | return cp, len(cp.options(section)) | ||||
@@ -14,7 +14,7 @@ import sys | |||||
# new line | # new line | ||||
NL = '\r\n' | NL = '\r\n' | ||||
_width = len(repr(sys.maxint - 1)) | |||||
_width = len(repr(sys.maxsize - 1)) | |||||
_fmt = '%%0%dd' % _width | _fmt = '%%0%dd' % _width | ||||
@@ -38,8 +38,8 @@ class MIMEMessage: | |||||
# maybe I can save some memory | # maybe I can save some memory | ||||
del alltext | del alltext | ||||
del msgparts | del msgparts | ||||
self._startCID = "<" + (_fmt % random.randrange(sys.maxint)) \ | |||||
+ (_fmt % random.randrange(sys.maxint)) + ">" | |||||
self._startCID = "<" + (_fmt % random.randrange(sys.maxsize)) \ | |||||
+ (_fmt % random.randrange(sys.maxsize)) + ">" | |||||
def toString(self): | def toString(self): | ||||
'''it return a string with the MIME message''' | '''it return a string with the MIME message''' | ||||
@@ -95,7 +95,7 @@ def _make_boundary(text=None): | |||||
# some code taken from python stdlib | # some code taken from python stdlib | ||||
# Craft a random boundary. If text is given, ensure that the chosen | # Craft a random boundary. If text is given, ensure that the chosen | ||||
# boundary doesn't appear in the text. | # boundary doesn't appear in the text. | ||||
token = random.randrange(sys.maxint) | |||||
token = random.randrange(sys.maxsize) | |||||
boundary = ('=' * 10) + (_fmt % token) + '==' | boundary = ('=' * 10) + (_fmt % token) + '==' | ||||
if text is None: | if text is None: | ||||
return boundary | return boundary | ||||
@@ -22,9 +22,9 @@ import six | |||||
import socket | import socket | ||||
import weakref | import weakref | ||||
from os.path import isfile | from os.path import isfile | ||||
import urllib | |||||
import urllib.request, urllib.parse, urllib.error | |||||
try: | try: | ||||
from urlparse import urljoin as basejoin # noqa | |||||
from urllib.parse import urljoin as basejoin # noqa | |||||
except ImportError: | except ImportError: | ||||
from urllib.parse import urljoin as basejoin # noqa | from urllib.parse import urljoin as basejoin # noqa | ||||
@@ -40,15 +40,15 @@ from .TimeoutSocket import TimeoutSocket, TimeoutError # noqa | |||||
try: | try: | ||||
from io import StringIO | from io import StringIO | ||||
except ImportError: | except ImportError: | ||||
from cStringIO import StringIO | |||||
from io import StringIO | |||||
try: | try: | ||||
from urlparse import urlparse | |||||
from urllib.parse import urlparse | |||||
except ImportError: | except ImportError: | ||||
from urllib.parse import urlparse | from urllib.parse import urlparse | ||||
try: | try: | ||||
from httplib import HTTPConnection, HTTPSConnection, FakeSocket, _CS_REQ_SENT | |||||
from http.client import HTTPConnection, HTTPSConnection, FakeSocket, _CS_REQ_SENT | |||||
except ImportError: | except ImportError: | ||||
from http.client import HTTPConnection, HTTPSConnection, _CS_REQ_SENT | from http.client import HTTPConnection, HTTPSConnection, _CS_REQ_SENT | ||||
import io | import io | ||||
@@ -219,7 +219,7 @@ def urlopen(url, timeout=20, redirects=None): | |||||
scheme, host, path, params, query, frag = urlparse(url) | scheme, host, path, params, query, frag = urlparse(url) | ||||
if scheme not in ('http', 'https'): | if scheme not in ('http', 'https'): | ||||
return urllib.urlopen(url) | |||||
return urllib.request.urlopen(url) | |||||
if params: | if params: | ||||
path = '%s;%s' % (path, params) | path = '%s;%s' % (path, params) | ||||
if query: | if query: | ||||
@@ -379,7 +379,7 @@ class DOM: | |||||
NS_XSD_01: NS_XSI_01, | NS_XSD_01: NS_XSI_01, | ||||
} | } | ||||
for key, value in copy.deepcopy(_xsd_uri_mapping).items(): | |||||
for key, value in list(copy.deepcopy(_xsd_uri_mapping).items()): | |||||
_xsd_uri_mapping[value] = key | _xsd_uri_mapping[value] = key | ||||
def InstanceUriForSchemaUri(self, uri): | def InstanceUriForSchemaUri(self, uri): | ||||
@@ -564,7 +564,7 @@ class DOM: | |||||
if node._attrsNS is None: | if node._attrsNS is None: | ||||
result = None | result = None | ||||
else: | else: | ||||
for item in node._attrsNS.keys(): | |||||
for item in list(node._attrsNS.keys()): | |||||
if item[1] == name: | if item[1] == name: | ||||
result = node._attrsNS[item] | result = node._attrsNS[item] | ||||
break | break | ||||
@@ -586,7 +586,7 @@ class DOM: | |||||
"""Return a Collection of all attributes | """Return a Collection of all attributes | ||||
""" | """ | ||||
attrs = {} | attrs = {} | ||||
for k, v in node._attrs.items(): | |||||
for k, v in list(node._attrs.items()): | |||||
attrs[k] = v.value | attrs[k] = v.value | ||||
return attrs | return attrs | ||||
@@ -840,7 +840,7 @@ class ElementProxy(Base, MessageInterface): | |||||
Base.__init__(self) | Base.__init__(self) | ||||
self._dom = DOM | self._dom = DOM | ||||
self.node = None | self.node = None | ||||
if type(message) in (types.StringType, types.UnicodeType): | |||||
if type(message) in (bytes, str): | |||||
self.loadFromString(message) | self.loadFromString(message) | ||||
elif isinstance(message, ElementProxy): | elif isinstance(message, ElementProxy): | ||||
self.node = message._getNode() | self.node = message._getNode() | ||||
@@ -863,7 +863,7 @@ class ElementProxy(Base, MessageInterface): | |||||
context = XPath.Context.Context(self.node, | context = XPath.Context.Context(self.node, | ||||
processorNss=processorNss) | processorNss=processorNss) | ||||
nodes = expression.evaluate(context) | nodes = expression.evaluate(context) | ||||
return map(lambda node: ElementProxy(self.sw, node), nodes) | |||||
return [ElementProxy(self.sw, node) for node in nodes] | |||||
############################################# | ############################################# | ||||
# Methods for checking/setting the | # Methods for checking/setting the | ||||
@@ -943,7 +943,7 @@ class ElementProxy(Base, MessageInterface): | |||||
if nsuri == XMLNS.XML: | if nsuri == XMLNS.XML: | ||||
return self._xml_prefix | return self._xml_prefix | ||||
if node.nodeType == Node.ELEMENT_NODE: | if node.nodeType == Node.ELEMENT_NODE: | ||||
for attr in node.attributes.values(): | |||||
for attr in list(node.attributes.values()): | |||||
if attr.namespaceURI == XMLNS.BASE \ | if attr.namespaceURI == XMLNS.BASE \ | ||||
and nsuri == attr.value: | and nsuri == attr.value: | ||||
return attr.localName | return attr.localName | ||||
@@ -1041,7 +1041,7 @@ class ElementProxy(Base, MessageInterface): | |||||
self.node = document.childNodes[0] | self.node = document.childNodes[0] | ||||
# set up reserved namespace attributes | # set up reserved namespace attributes | ||||
for prefix, nsuri in self.reserved_ns.items(): | |||||
for prefix, nsuri in list(self.reserved_ns.items()): | |||||
self._setAttributeNS(namespaceURI=self._xmlns_nsuri, | self._setAttributeNS(namespaceURI=self._xmlns_nsuri, | ||||
qualifiedName='%s:%s' % (self._xmlns_prefix, | qualifiedName='%s:%s' % (self._xmlns_prefix, | ||||
prefix), | prefix), | ||||
@@ -1247,10 +1247,10 @@ class Collection(UserDict): | |||||
self.data[key] = item | self.data[key] = item | ||||
def keys(self): | def keys(self): | ||||
return map(lambda i: self._func(i), self.list) | |||||
return [self._func(i) for i in self.list] | |||||
def items(self): | def items(self): | ||||
return map(lambda i: (self._func(i), i), self.list) | |||||
return [(self._func(i), i) for i in self.list] | |||||
def values(self): | def values(self): | ||||
return self.list | return self.list | ||||
@@ -1293,13 +1293,12 @@ class CollectionNS(UserDict): | |||||
def keys(self): | def keys(self): | ||||
keys = [] | keys = [] | ||||
for tns in self.data.keys(): | |||||
keys.append(map(lambda i: (tns, self._func(i)), | |||||
self.data[tns].values())) | |||||
for tns in list(self.data.keys()): | |||||
keys.append([(tns, self._func(i)) for i in list(self.data[tns].values())]) | |||||
return keys | return keys | ||||
def items(self): | def items(self): | ||||
return map(lambda i: (self._func(i), i), self.list) | |||||
return [(self._func(i), i) for i in self.list] | |||||
def values(self): | def values(self): | ||||
return self.list | return self.list | ||||
@@ -1351,7 +1350,7 @@ if 1: | |||||
else: | else: | ||||
node = self.buildDocument(None, localname) | node = self.buildDocument(None, localname) | ||||
for aname, value in attrs.items(): | |||||
for aname, value in list(attrs.items()): | |||||
a_uri, a_localname = aname | a_uri, a_localname = aname | ||||
if a_uri == xmlns_uri: | if a_uri == xmlns_uri: | ||||
if a_localname == 'xmlns': | if a_localname == 'xmlns': | ||||
@@ -1409,7 +1408,7 @@ if 1: | |||||
if node.nodeType == xml.dom.minidom.Node.ELEMENT_NODE: | if node.nodeType == xml.dom.minidom.Node.ELEMENT_NODE: | ||||
clone = newOwnerDocument.createElementNS(node.namespaceURI, | clone = newOwnerDocument.createElementNS(node.namespaceURI, | ||||
node.nodeName) | node.nodeName) | ||||
for attr in node.attributes.values(): | |||||
for attr in list(node.attributes.values()): | |||||
clone.setAttributeNS(attr.namespaceURI, attr.nodeName, | clone.setAttributeNS(attr.namespaceURI, attr.nodeName, | ||||
attr.value) | attr.value) | ||||
@@ -15,7 +15,7 @@ import logging | |||||
try: | try: | ||||
from io import StringIO | from io import StringIO | ||||
except ImportError: | except ImportError: | ||||
from cStringIO import StringIO | |||||
from io import StringIO | |||||
from .Namespaces import OASIS, XMLNS, WSA, WSA_LIST, WSAW_LIST, WSRF_V1_2, WSRF # noqa | from .Namespaces import OASIS, XMLNS, WSA, WSA_LIST, WSAW_LIST, WSRF_V1_2, WSRF # noqa | ||||
from .Utility import Collection, CollectionNS, DOM, ElementProxy, basejoin # noqa | from .Utility import Collection, CollectionNS, DOM, ElementProxy, basejoin # noqa | ||||
@@ -364,7 +364,7 @@ class WSDL: | |||||
parent.appendChild(child) | parent.appendChild(child) | ||||
child.setAttribute('targetNamespace', namespace) | child.setAttribute('targetNamespace', namespace) | ||||
attrsNS = imported._attrsNS | attrsNS = imported._attrsNS | ||||
for attrkey in attrsNS.keys(): | |||||
for attrkey in list(attrsNS.keys()): | |||||
if attrkey[0] == DOM.NS_XMLNS: | if attrkey[0] == DOM.NS_XMLNS: | ||||
attr = attrsNS[attrkey].cloneNode(1) | attr = attrsNS[attrkey].cloneNode(1) | ||||
child.setAttributeNode(attr) | child.setAttributeNode(attr) | ||||
@@ -1246,7 +1246,7 @@ class SoapBodyBinding: | |||||
) | ) | ||||
self.encodingStyle = encodingStyle | self.encodingStyle = encodingStyle | ||||
self.namespace = namespace | self.namespace = namespace | ||||
if type(parts) in (type(''), type(u'')): | |||||
if type(parts) in (type(''), type('')): | |||||
parts = parts.split() | parts = parts.split() | ||||
self.parts = parts | self.parts = parts | ||||
self.use = use | self.use = use | ||||
@@ -1673,7 +1673,7 @@ def callInfoFromWSDL(self, port, name): | |||||
for name in body.parts: | for name in body.parts: | ||||
parts.append(message.parts[name]) | parts.append(message.parts[name]) | ||||
else: | else: | ||||
parts = message.parts.values() | |||||
parts = list(message.parts.values()) | |||||
for part in parts: | for part in parts: | ||||
callinfo.addInParameter( | callinfo.addInParameter( | ||||
@@ -1724,7 +1724,7 @@ def callInfoFromWSDL(self, port, name): | |||||
for name in body.parts: | for name in body.parts: | ||||
parts.append(message.parts[name]) | parts.append(message.parts[name]) | ||||
else: | else: | ||||
parts = message.parts.values() | |||||
parts = list(message.parts.values()) | |||||
if parts: | if parts: | ||||
for part in parts: | for part in parts: | ||||
@@ -33,7 +33,7 @@ from .Utility import SplitQName | |||||
from .Utility import basejoin | from .Utility import basejoin | ||||
try: | try: | ||||
from StringIO import StringIO | |||||
from io import StringIO | |||||
except ImportError: | except ImportError: | ||||
# from io import StringIO | # from io import StringIO | ||||
from io import BytesIO as StringIO | from io import BytesIO as StringIO | ||||
@@ -96,7 +96,7 @@ class SchemaReader(object): | |||||
schema -- XMLSchema instance | schema -- XMLSchema instance | ||||
""" | """ | ||||
for ns, val in schema.imports.items(): | |||||
for ns, val in list(schema.imports.items()): | |||||
if ns in self._imports: | if ns in self._imports: | ||||
schema.addImportSchema(self._imports[ns]) | schema.addImportSchema(self._imports[ns]) | ||||
@@ -105,7 +105,7 @@ class SchemaReader(object): | |||||
schema -- XMLSchema instance | schema -- XMLSchema instance | ||||
""" | """ | ||||
for schemaLocation, val in schema.includes.items(): | |||||
for schemaLocation, val in list(schema.includes.items()): | |||||
if schemaLocation in self._includes: | if schemaLocation in self._includes: | ||||
schema.addIncludeSchema( | schema.addIncludeSchema( | ||||
schemaLocation, self._imports[schemaLocation]) | schemaLocation, self._imports[schemaLocation]) | ||||
@@ -303,12 +303,12 @@ class DOMAdapter(DOMAdapterInterface): | |||||
if child.nodeType == ELEMENT_NODE and\ | if child.nodeType == ELEMENT_NODE and\ | ||||
SplitQName(child.tagName)[1] in contents: | SplitQName(child.tagName)[1] in contents: | ||||
nodes.append(child) | nodes.append(child) | ||||
return map(self.__class__, nodes) | |||||
return list(map(self.__class__, nodes)) | |||||
def setAttributeDictionary(self): | def setAttributeDictionary(self): | ||||
self.__attributes = {} | self.__attributes = {} | ||||
if self.__node._attrs: | if self.__node._attrs: | ||||
for v in self.__node._attrs.values(): | |||||
for v in list(self.__node._attrs.values()): | |||||
self.__attributes[v.nodeName] = v.nodeValue | self.__attributes[v.nodeName] = v.nodeValue | ||||
def getAttributeDictionary(self): | def getAttributeDictionary(self): | ||||
@@ -364,7 +364,7 @@ class XMLBase: | |||||
XMLBase.__rlock.acquire() | XMLBase.__rlock.acquire() | ||||
XMLBase.__indent += 1 | XMLBase.__indent += 1 | ||||
tmp = "<" + str(self.__class__) + '>\n' | tmp = "<" + str(self.__class__) + '>\n' | ||||
for k, v in self.__dict__.items(): | |||||
for k, v in list(self.__dict__.items()): | |||||
tmp += "%s* %s = %s\n" % (XMLBase.__indent * ' ', k, v) | tmp += "%s* %s = %s\n" % (XMLBase.__indent * ' ', k, v) | ||||
XMLBase.__indent -= 1 | XMLBase.__indent -= 1 | ||||
XMLBase.__rlock.release() | XMLBase.__rlock.release() | ||||
@@ -807,7 +807,7 @@ class XMLSchemaComponent(XMLBase, MarkerInterface): | |||||
with QName. | with QName. | ||||
""" | """ | ||||
self.attributes = {XMLSchemaComponent.xmlns: {}} | self.attributes = {XMLSchemaComponent.xmlns: {}} | ||||
for k, v in node.getAttributeDictionary().items(): | |||||
for k, v in list(node.getAttributeDictionary().items()): | |||||
prefix, value = SplitQName(k) | prefix, value = SplitQName(k) | ||||
if value == XMLSchemaComponent.xmlns: | if value == XMLSchemaComponent.xmlns: | ||||
self.attributes[value][ | self.attributes[value][ | ||||
@@ -861,7 +861,7 @@ class XMLSchemaComponent(XMLBase, MarkerInterface): | |||||
class variable representing attribute is None, then | class variable representing attribute is None, then | ||||
it must be defined as an instance variable. | it must be defined as an instance variable. | ||||
""" | """ | ||||
for k, v in self.__class__.attributes.items(): | |||||
for k, v in list(self.__class__.attributes.items()): | |||||
if v is not None and k in self.attributes is False: | if v is not None and k in self.attributes is False: | ||||
if isinstance(v, types.FunctionType): | if isinstance(v, types.FunctionType): | ||||
self.attributes[k] = v(self) | self.attributes[k] = v(self) | ||||
@@ -878,7 +878,7 @@ class XMLSchemaComponent(XMLBase, MarkerInterface): | |||||
if a not in self.attributes: | if a not in self.attributes: | ||||
raise SchemaError( | raise SchemaError( | ||||
'class instance %s, missing required attribute %s' % (self.__class__, a)) | 'class instance %s, missing required attribute %s' % (self.__class__, a)) | ||||
for a, v in self.attributes.items(): | |||||
for a, v in list(self.attributes.items()): | |||||
# attribute #other, ie. not in empty namespace | # attribute #other, ie. not in empty namespace | ||||
if type(v) is dict: | if type(v) is dict: | ||||
continue | continue | ||||
@@ -887,7 +887,7 @@ class XMLSchemaComponent(XMLBase, MarkerInterface): | |||||
if a in (XMLSchemaComponent.xmlns, XMLNS.XML): | if a in (XMLSchemaComponent.xmlns, XMLNS.XML): | ||||
continue | continue | ||||
if (a not in self.__class__.attributes.keys()) and not\ | |||||
if (a not in list(self.__class__.attributes.keys())) and not\ | |||||
(self.isAttribute() and self.isReference()): | (self.isAttribute() and self.isReference()): | ||||
raise SchemaError('%s, unknown attribute(%s, %s)' % ( | raise SchemaError('%s, unknown attribute(%s, %s)' % ( | ||||
self.getItemTrace(), a, self.attributes[a])) | self.getItemTrace(), a, self.attributes[a])) | ||||
@@ -1267,7 +1267,7 @@ class XMLSchema(XMLSchemaComponent): | |||||
self.setAttributes(pnode) | self.setAttributes(pnode) | ||||
attributes.update(self.attributes) | attributes.update(self.attributes) | ||||
self.setAttributes(node) | self.setAttributes(node) | ||||
for k, v in attributes['xmlns'].items(): | |||||
for k, v in list(attributes['xmlns'].items()): | |||||
if k not in self.attributes['xmlns']: | if k not in self.attributes['xmlns']: | ||||
self.attributes['xmlns'][k] = v | self.attributes['xmlns'][k] = v | ||||
else: | else: | ||||
@@ -1299,7 +1299,7 @@ class XMLSchema(XMLSchemaComponent): | |||||
for collection in ['imports', 'elements', 'types', | for collection in ['imports', 'elements', 'types', | ||||
'attr_decl', 'attr_groups', 'model_groups', | 'attr_decl', 'attr_groups', 'model_groups', | ||||
'notations']: | 'notations']: | ||||
for k, v in getattr(schema, collection).items(): | |||||
for k, v in list(getattr(schema, collection).items()): | |||||
if k not in getattr(self, collection): | if k not in getattr(self, collection): | ||||
v._parent = weakref.ref(self) | v._parent = weakref.ref(self) | ||||
getattr(self, collection)[k] = v | getattr(self, collection)[k] = v | ||||
@@ -2049,7 +2049,7 @@ class ElementDeclaration(XMLSchemaComponent, | |||||
parent = self | parent = self | ||||
while 1: | while 1: | ||||
nsdict = parent.attributes[XMLSchemaComponent.xmlns] | nsdict = parent.attributes[XMLSchemaComponent.xmlns] | ||||
for k, v in nsdict.items(): | |||||
for k, v in list(nsdict.items()): | |||||
if v not in SCHEMA.XSD_LIST: | if v not in SCHEMA.XSD_LIST: | ||||
continue | continue | ||||
return TypeDescriptionComponent((v, 'anyType')) | return TypeDescriptionComponent((v, 'anyType')) | ||||
@@ -3264,7 +3264,7 @@ class Redefine: | |||||
if sys.version_info[:2] >= (2, 2): | if sys.version_info[:2] >= (2, 2): | ||||
tupleClass = tuple | tupleClass = tuple | ||||
else: | else: | ||||
import UserTuple | |||||
from . import UserTuple | |||||
tupleClass = UserTuple.UserTuple | tupleClass = UserTuple.UserTuple | ||||
@@ -70,21 +70,21 @@ def toXMLname(string): | |||||
N = len(localname) | N = len(localname) | ||||
X = [] | X = [] | ||||
for i in range(N): | for i in range(N): | ||||
if i < N - 1 and T[i] == u'_' and T[i + 1] == u'x': | |||||
X.append(u'_x005F_') | |||||
if i < N - 1 and T[i] == '_' and T[i + 1] == 'x': | |||||
X.append('_x005F_') | |||||
elif i == 0 and N >= 3 and \ | elif i == 0 and N >= 3 and \ | ||||
(T[0] == u'x' or T[0] == u'X') and \ | |||||
(T[1] == u'm' or T[1] == u'M') and \ | |||||
(T[2] == u'l' or T[2] == u'L'): | |||||
X.append(u'_xFFFF_' + T[0]) | |||||
(T[0] == 'x' or T[0] == 'X') and \ | |||||
(T[1] == 'm' or T[1] == 'M') and \ | |||||
(T[2] == 'l' or T[2] == 'L'): | |||||
X.append('_xFFFF_' + T[0]) | |||||
elif (not _NCNameChar(T[i])) or (i == 0 and not _NCNameStartChar(T[i])): | elif (not _NCNameChar(T[i])) or (i == 0 and not _NCNameStartChar(T[i])): | ||||
X.append(_toUnicodeHex(T[i])) | X.append(_toUnicodeHex(T[i])) | ||||
else: | else: | ||||
X.append(T[i]) | X.append(T[i]) | ||||
if prefix: | if prefix: | ||||
return "%s:%s" % (prefix, u''.join(X)) | |||||
return u''.join(X) | |||||
return "%s:%s" % (prefix, ''.join(X)) | |||||
return ''.join(X) | |||||
def fromXMLname(string): | def fromXMLname(string): | ||||
@@ -12,7 +12,7 @@ except ImportError: | |||||
try: | try: | ||||
from io import StringIO | from io import StringIO | ||||
except ImportError: | except ImportError: | ||||
from cStringIO import StringIO | |||||
from io import StringIO | |||||
'''XML Canonicalization | '''XML Canonicalization | ||||