Browse Source

Converted with 2to3-3.5

main
Jarrod Chesney 7 years ago
parent
commit
8983b034e7
8 changed files with 61 additions and 62 deletions
  1. +2
    -2
      setup.py
  2. +7
    -7
      tests/test_wsdl.py
  3. +4
    -4
      wstools/MIMEAttachment.py
  4. +20
    -21
      wstools/Utility.py
  5. +5
    -5
      wstools/WSDLTools.py
  6. +14
    -14
      wstools/XMLSchema.py
  7. +8
    -8
      wstools/XMLname.py
  8. +1
    -1
      wstools/c14n.py

+ 2
- 2
setup.py View File

@@ -84,7 +84,7 @@ class Release(Command):
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
from urllib.request import urlopen
response = urlopen(
"http://pypi.python.org/pypi/%s/json" % NAME)
data = json.load(codecs.getreader("utf-8")(response))
@@ -114,7 +114,7 @@ class PreRelease(Command):
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
from urllib.request import urlopen
response = urlopen(
"http://pypi.python.org/pypi/%s/json" % NAME)
data = json.load(codecs.getreader("utf-8")(response))


+ 7
- 7
tests/test_wsdl.py View File

@@ -50,7 +50,7 @@ class WSDLToolsTestCase(unittest.TestCase):
if hasattr(nameGenerator, '__next__'):
self.path = nameGenerator.__next__()
else:
self.path = nameGenerator.next()
self.path = next(nameGenerator)
# print(self.path)
sys.stdout.flush()

@@ -70,7 +70,7 @@ class WSDLToolsTestCase(unittest.TestCase):
for node in DOM.getElements(definition, tag_name, nspname):
name = DOM.getAttr(node, key)
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'):
for cnode in DOM.getElements(node, tag_name):
@@ -124,9 +124,9 @@ class WSDLToolsTestCase(unittest.TestCase):
raise

try:
for key in self.wsdl.types.keys():
for key in list(self.wsdl.types.keys()):
schema = self.wsdl.types[key]
self.failUnlessEqual(key, schema.getTargetNamespace())
self.assertEqual(key, schema.getTargetNamespace())

definition = self.wsdl.document.documentElement
version = DOM.WSDLUriToVersion(definition.namespaceURI)
@@ -144,9 +144,9 @@ class WSDLToolsTestCase(unittest.TestCase):
raise

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:
print('\t', ext)
print(('\t', ext))

def schemaAttributesDeclarations(self, schema, node):
self.checkXSDCollection('attribute', schema.attr_decl, node)
@@ -170,7 +170,7 @@ def setUpOptions(section):
print('fatal error: configuration file config.txt not present')
sys.exit(0)
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)
return cp, len(cp.options(section))



+ 4
- 4
wstools/MIMEAttachment.py View File

@@ -14,7 +14,7 @@ import sys
# new line
NL = '\r\n'

_width = len(repr(sys.maxint - 1))
_width = len(repr(sys.maxsize - 1))
_fmt = '%%0%dd' % _width


@@ -38,8 +38,8 @@ class MIMEMessage:
# maybe I can save some memory
del alltext
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):
'''it return a string with the MIME message'''
@@ -95,7 +95,7 @@ def _make_boundary(text=None):
# some code taken from python stdlib
# Craft a random boundary. If text is given, ensure that the chosen
# boundary doesn't appear in the text.
token = random.randrange(sys.maxint)
token = random.randrange(sys.maxsize)
boundary = ('=' * 10) + (_fmt % token) + '=='
if text is None:
return boundary


+ 20
- 21
wstools/Utility.py View File

@@ -22,9 +22,9 @@ import six
import socket
import weakref
from os.path import isfile
import urllib
import urllib.request, urllib.parse, urllib.error
try:
from urlparse import urljoin as basejoin # noqa
from urllib.parse import urljoin as basejoin # noqa
except ImportError:
from urllib.parse import urljoin as basejoin # noqa

@@ -40,15 +40,15 @@ from .TimeoutSocket import TimeoutSocket, TimeoutError # noqa
try:
from io import StringIO
except ImportError:
from cStringIO import StringIO
from io import StringIO

try:
from urlparse import urlparse
from urllib.parse import urlparse
except ImportError:
from urllib.parse import urlparse

try:
from httplib import HTTPConnection, HTTPSConnection, FakeSocket, _CS_REQ_SENT
from http.client import HTTPConnection, HTTPSConnection, FakeSocket, _CS_REQ_SENT
except ImportError:
from http.client import HTTPConnection, HTTPSConnection, _CS_REQ_SENT
import io
@@ -219,7 +219,7 @@ def urlopen(url, timeout=20, redirects=None):
scheme, host, path, params, query, frag = urlparse(url)

if scheme not in ('http', 'https'):
return urllib.urlopen(url)
return urllib.request.urlopen(url)
if params:
path = '%s;%s' % (path, params)
if query:
@@ -379,7 +379,7 @@ class DOM:
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

def InstanceUriForSchemaUri(self, uri):
@@ -564,7 +564,7 @@ class DOM:
if node._attrsNS is None:
result = None
else:
for item in node._attrsNS.keys():
for item in list(node._attrsNS.keys()):
if item[1] == name:
result = node._attrsNS[item]
break
@@ -586,7 +586,7 @@ class DOM:
"""Return a Collection of all attributes
"""
attrs = {}
for k, v in node._attrs.items():
for k, v in list(node._attrs.items()):
attrs[k] = v.value
return attrs

@@ -840,7 +840,7 @@ class ElementProxy(Base, MessageInterface):
Base.__init__(self)
self._dom = DOM
self.node = None
if type(message) in (types.StringType, types.UnicodeType):
if type(message) in (bytes, str):
self.loadFromString(message)
elif isinstance(message, ElementProxy):
self.node = message._getNode()
@@ -863,7 +863,7 @@ class ElementProxy(Base, MessageInterface):
context = XPath.Context.Context(self.node,
processorNss=processorNss)
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
@@ -943,7 +943,7 @@ class ElementProxy(Base, MessageInterface):
if nsuri == XMLNS.XML:
return self._xml_prefix
if node.nodeType == Node.ELEMENT_NODE:
for attr in node.attributes.values():
for attr in list(node.attributes.values()):
if attr.namespaceURI == XMLNS.BASE \
and nsuri == attr.value:
return attr.localName
@@ -1041,7 +1041,7 @@ class ElementProxy(Base, MessageInterface):
self.node = document.childNodes[0]

# 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,
qualifiedName='%s:%s' % (self._xmlns_prefix,
prefix),
@@ -1247,10 +1247,10 @@ class Collection(UserDict):
self.data[key] = item

def keys(self):
return map(lambda i: self._func(i), self.list)
return [self._func(i) for i in self.list]

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):
return self.list
@@ -1293,13 +1293,12 @@ class CollectionNS(UserDict):

def keys(self):
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

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):
return self.list
@@ -1351,7 +1350,7 @@ if 1:
else:
node = self.buildDocument(None, localname)

for aname, value in attrs.items():
for aname, value in list(attrs.items()):
a_uri, a_localname = aname
if a_uri == xmlns_uri:
if a_localname == 'xmlns':
@@ -1409,7 +1408,7 @@ if 1:
if node.nodeType == xml.dom.minidom.Node.ELEMENT_NODE:
clone = newOwnerDocument.createElementNS(node.namespaceURI,
node.nodeName)
for attr in node.attributes.values():
for attr in list(node.attributes.values()):
clone.setAttributeNS(attr.namespaceURI, attr.nodeName,
attr.value)



+ 5
- 5
wstools/WSDLTools.py View File

@@ -15,7 +15,7 @@ import logging
try:
from io import StringIO
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 .Utility import Collection, CollectionNS, DOM, ElementProxy, basejoin # noqa
@@ -364,7 +364,7 @@ class WSDL:
parent.appendChild(child)
child.setAttribute('targetNamespace', namespace)
attrsNS = imported._attrsNS
for attrkey in attrsNS.keys():
for attrkey in list(attrsNS.keys()):
if attrkey[0] == DOM.NS_XMLNS:
attr = attrsNS[attrkey].cloneNode(1)
child.setAttributeNode(attr)
@@ -1246,7 +1246,7 @@ class SoapBodyBinding:
)
self.encodingStyle = encodingStyle
self.namespace = namespace
if type(parts) in (type(''), type(u'')):
if type(parts) in (type(''), type('')):
parts = parts.split()
self.parts = parts
self.use = use
@@ -1673,7 +1673,7 @@ def callInfoFromWSDL(self, port, name):
for name in body.parts:
parts.append(message.parts[name])
else:
parts = message.parts.values()
parts = list(message.parts.values())

for part in parts:
callinfo.addInParameter(
@@ -1724,7 +1724,7 @@ def callInfoFromWSDL(self, port, name):
for name in body.parts:
parts.append(message.parts[name])
else:
parts = message.parts.values()
parts = list(message.parts.values())

if parts:
for part in parts:


+ 14
- 14
wstools/XMLSchema.py View File

@@ -33,7 +33,7 @@ from .Utility import SplitQName
from .Utility import basejoin

try:
from StringIO import StringIO
from io import StringIO
except ImportError:
# from io import StringIO
from io import BytesIO as StringIO
@@ -96,7 +96,7 @@ class SchemaReader(object):

schema -- XMLSchema instance
"""
for ns, val in schema.imports.items():
for ns, val in list(schema.imports.items()):
if ns in self._imports:
schema.addImportSchema(self._imports[ns])

@@ -105,7 +105,7 @@ class SchemaReader(object):

schema -- XMLSchema instance
"""
for schemaLocation, val in schema.includes.items():
for schemaLocation, val in list(schema.includes.items()):
if schemaLocation in self._includes:
schema.addIncludeSchema(
schemaLocation, self._imports[schemaLocation])
@@ -303,12 +303,12 @@ class DOMAdapter(DOMAdapterInterface):
if child.nodeType == ELEMENT_NODE and\
SplitQName(child.tagName)[1] in contents:
nodes.append(child)
return map(self.__class__, nodes)
return list(map(self.__class__, nodes))

def setAttributeDictionary(self):
self.__attributes = {}
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

def getAttributeDictionary(self):
@@ -364,7 +364,7 @@ class XMLBase:
XMLBase.__rlock.acquire()
XMLBase.__indent += 1
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)
XMLBase.__indent -= 1
XMLBase.__rlock.release()
@@ -807,7 +807,7 @@ class XMLSchemaComponent(XMLBase, MarkerInterface):
with QName.
"""
self.attributes = {XMLSchemaComponent.xmlns: {}}
for k, v in node.getAttributeDictionary().items():
for k, v in list(node.getAttributeDictionary().items()):
prefix, value = SplitQName(k)
if value == XMLSchemaComponent.xmlns:
self.attributes[value][
@@ -861,7 +861,7 @@ class XMLSchemaComponent(XMLBase, MarkerInterface):
class variable representing attribute is None, then
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 isinstance(v, types.FunctionType):
self.attributes[k] = v(self)
@@ -878,7 +878,7 @@ class XMLSchemaComponent(XMLBase, MarkerInterface):
if a not in self.attributes:
raise SchemaError(
'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
if type(v) is dict:
continue
@@ -887,7 +887,7 @@ class XMLSchemaComponent(XMLBase, MarkerInterface):
if a in (XMLSchemaComponent.xmlns, XMLNS.XML):
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()):
raise SchemaError('%s, unknown attribute(%s, %s)' % (
self.getItemTrace(), a, self.attributes[a]))
@@ -1267,7 +1267,7 @@ class XMLSchema(XMLSchemaComponent):
self.setAttributes(pnode)
attributes.update(self.attributes)
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']:
self.attributes['xmlns'][k] = v
else:
@@ -1299,7 +1299,7 @@ class XMLSchema(XMLSchemaComponent):
for collection in ['imports', 'elements', 'types',
'attr_decl', 'attr_groups', 'model_groups',
'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):
v._parent = weakref.ref(self)
getattr(self, collection)[k] = v
@@ -2049,7 +2049,7 @@ class ElementDeclaration(XMLSchemaComponent,
parent = self
while 1:
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:
continue
return TypeDescriptionComponent((v, 'anyType'))
@@ -3264,7 +3264,7 @@ class Redefine:
if sys.version_info[:2] >= (2, 2):
tupleClass = tuple
else:
import UserTuple
from . import UserTuple
tupleClass = UserTuple.UserTuple




+ 8
- 8
wstools/XMLname.py View File

@@ -70,21 +70,21 @@ def toXMLname(string):
N = len(localname)
X = []
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 \
(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])):
X.append(_toUnicodeHex(T[i]))
else:
X.append(T[i])

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):


+ 1
- 1
wstools/c14n.py View File

@@ -12,7 +12,7 @@ except ImportError:
try:
from io import StringIO
except ImportError:
from cStringIO import StringIO
from io import StringIO

'''XML Canonicalization



Loading…
Cancel
Save