Browse Source

add more fixes

main
jordism 8 years ago
parent
commit
11946902ea
10 changed files with 103 additions and 101 deletions
  1. +1
    -0
      .gitignore
  2. +2
    -2
      src/SOAPpy/Client.py
  3. +1
    -1
      src/SOAPpy/Config.py
  4. +1
    -1
      src/SOAPpy/GSIServer.py
  5. +22
    -21
      src/SOAPpy/Parser.py
  6. +3
    -3
      src/SOAPpy/SOAPBuilder.py
  7. +2
    -2
      src/SOAPpy/Server.py
  8. +61
    -61
      src/SOAPpy/Types.py
  9. +1
    -1
      src/SOAPpy/Utilities.py
  10. +9
    -9
      src/SOAPpy/__init__.py

+ 1
- 0
.gitignore View File

@@ -5,3 +5,4 @@ dist/
setup.cfg setup.cfg
venv/ venv/
*.pyc *.pyc
.idea

+ 2
- 2
src/SOAPpy/Client.py View File

@@ -48,7 +48,7 @@ from .version import __version__


#import xml.sax #import xml.sax
import urllib.request, urllib.parse, urllib.error import urllib.request, urllib.parse, urllib.error
from .types import *
from SOAPpy.Types import *
import re import re
import base64 import base64
import socket, http.client import socket, http.client
@@ -61,7 +61,7 @@ from .Config import Config
from .Parser import parseSOAPRPC from .Parser import parseSOAPRPC
from .SOAPBuilder import buildSOAP from .SOAPBuilder import buildSOAP
from .Utilities import * from .Utilities import *
from .types import faultType, simplify
from SOAPpy.Types import faultType, simplify


import collections import collections




+ 1
- 1
src/SOAPpy/Config.py View File

@@ -37,7 +37,7 @@ ident = '$Id: Config.py 1298 2006-11-07 00:54:15Z sanxiyn $'
from .version import __version__ from .version import __version__


import socket import socket
from .types import *
from SOAPpy.Types import *


from .NS import NS from .NS import NS




+ 1
- 1
src/SOAPpy/GSIServer.py View File

@@ -53,7 +53,7 @@ import re
import socket import socket
import sys import sys
import socketserver import socketserver
from .types import *
from SOAPpy.Types import *
import http.server import http.server


# SOAPpy modules # SOAPpy modules


+ 22
- 21
src/SOAPpy/Parser.py View File

@@ -1,7 +1,7 @@
# SOAPpy modules # SOAPpy modules
import traceback import traceback
from .Config import Config from .Config import Config
from .types import *
from SOAPpy.Types import *
from .NS import NS from .NS import NS
from .Utilities import * from .Utilities import *


@@ -151,7 +151,7 @@ class SOAPParser(xml.sax.handler.ContentHandler):
except: except:
rules = None rules = None


if type(rules) not in (NoneType, DictType):
if type(rules) not in (type(None), dict):
kind = rules kind = rules
else: else:
kind = attrs.get((NS.ENC, 'arrayType')) kind = attrs.get((NS.ENC, 'arrayType'))
@@ -376,8 +376,8 @@ class SOAPParser(xml.sax.handler.ContentHandler):


if len(self._stack) == 3 and kind == None and \ if len(self._stack) == 3 and kind == None and \
len(cur) == 0 and \ len(cur) == 0 and \
(self._data == None or string.join(self._data, "").strip() == ''):
data = structType(name = (ns, name), attrs = attrs)
(self._data is None or "".join(self._data).strip() == ''):
data = structType(name=(ns, name), attrs=attrs)
break break


if len(cur) == 0 and ns != NS.URN: if len(cur) == 0 and ns != NS.URN:
@@ -389,8 +389,7 @@ class SOAPParser(xml.sax.handler.ContentHandler):
# print "attrs:", attrs # print "attrs:", attrs
# print "kind:", kind # print "kind:", kind



if kind == None:
if kind is None:
# If the current item's container is an array, it will # If the current item's container is an array, it will
# have a kind. If so, get the bit before the first [, # have a kind. If so, get the bit before the first [,
# which is the type of the array, therefore the type of # which is the type of the array, therefore the type of
@@ -398,35 +397,37 @@ class SOAPParser(xml.sax.handler.ContentHandler):


kind = self._stack[-1].kind kind = self._stack[-1].kind


if kind != None:
if kind is not None:
i = kind[1].find('[') i = kind[1].find('[')
if i >= 0: if i >= 0:
kind = (kind[0], kind[1][:i]) kind = (kind[0], kind[1][:i])
elif ns != None:
elif ns is not None:
kind = (ns, name) kind = (ns, name)


if kind != None:
if kind is not None:
try: try:
data = self.convertType(string.join(self._data, ""),
data = self.convertType("".join(self._data),
kind, attrs) kind, attrs)
except UnknownTypeError: except UnknownTypeError:
data = None data = None
else: else:
data = None data = None


if data == None:
if self._data == None:
if data is None:
if self._data is None:
data = '' data = ''
else: else:
data = string.join(self._data, "")
data = "".join(self._data)


if len(attrs) == 0: if len(attrs) == 0:
try: data = str(data)
except: pass
try:
data = str(data)
except:
pass


break break


data = structType(name = (ns, name), attrs = attrs)
data = structType(name=(ns, name), attrs=attrs)


break break


@@ -441,7 +442,7 @@ class SOAPParser(xml.sax.handler.ContentHandler):
if root: if root:
self._stack[-1].append(name, data, attrs) self._stack[-1].append(name, data, attrs)


if idval != None:
if idval is not None:
self._ids[idval] = data self._ids[idval] = data


if idval in self._refs: if idval in self._refs:
@@ -475,7 +476,7 @@ class SOAPParser(xml.sax.handler.ContentHandler):
pass pass


def characters(self, c): def characters(self, c):
if self._data != None:
if self._data is not None:
self._data.append(c) self._data.append(c)


arrayre = '^(?:(?P<ns>[^:]*):)?' \ arrayre = '^(?:(?P<ns>[^:]*):)?' \
@@ -484,12 +485,12 @@ class SOAPParser(xml.sax.handler.ContentHandler):
'(?:\[(?P<asize>\d+(?:,\d+)*)?\])$' '(?:\[(?P<asize>\d+(?:,\d+)*)?\])$'


def startArray(self, name, kind, attrs, elemsname): def startArray(self, name, kind, attrs, elemsname):
if type(self.arrayre) == StringType:
self.arrayre = re.compile (self.arrayre)
if isinstance(self.arrayre, str):
self.arrayre = re.compile(self.arrayre)


offset = attrs.get((NS.ENC, "offset")) offset = attrs.get((NS.ENC, "offset"))


if offset != None:
if offset is not None:
del attrs[(NS.ENC, "offset")] del attrs[(NS.ENC, "offset")]


try: try:


+ 3
- 3
src/SOAPpy/SOAPBuilder.py View File

@@ -42,7 +42,7 @@ from wstools.XMLname import toXMLname, fromXMLname
# SOAPpy modules # SOAPpy modules
from .Config import Config from .Config import Config
from .NS import NS from .NS import NS
from .types import *
from SOAPpy.Types import *


# Test whether this Python version has Types.BooleanType # Test whether this Python version has Types.BooleanType
# If it doesn't have it, then False and True are serialized as integers # If it doesn't have it, then False and True are serialized as integers
@@ -282,7 +282,7 @@ class SOAPBuilder:
ns_map = ns_map.copy() ns_map = ns_map.copy()
self.depth += 1 self.depth += 1


if type(tag) not in (NoneType, StringType, UnicodeType):
if type(tag) not in (type(None), str):
raise KeyError("tag must be a string or None") raise KeyError("tag must be a string or None")


self.dump_dispatch(obj, tag, typed, ns_map) self.dump_dispatch(obj, tag, typed, ns_map)
@@ -607,7 +607,7 @@ class SOAPBuilder:
(mapType, self.dump_map), (mapType, self.dump_map),
(arrayType, self.dump_list), (arrayType, self.dump_list),
(str, self.dump_string), (str, self.dump_string),
(NoneType, self.dump_None),
(type(None), self.dump_None),
(bool, self.dump_bool), (bool, self.dump_bool),
(int, self.dump_int), (int, self.dump_int),
(int, self.dump_int), (int, self.dump_int),


+ 2
- 2
src/SOAPpy/Server.py View File

@@ -49,14 +49,14 @@ from .version import __version__
import socket import socket
import sys import sys
import socketserver import socketserver
from .types import *
from SOAPpy.Types import *
import http.server import http.server
import _thread import _thread


# SOAPpy modules # SOAPpy modules
from .Parser import parseSOAPRPC from .Parser import parseSOAPRPC
from .Config import Config from .Config import Config
from .types import faultType, voidType, simplify
from SOAPpy.Types import faultType, voidType, simplify
from .NS import NS from .NS import NS
from .SOAPBuilder import buildSOAP from .SOAPBuilder import buildSOAP
from .Utilities import debugHeader, debugFooter from .Utilities import debugHeader, debugFooter


+ 61
- 61
src/SOAPpy/Types.py View File

@@ -45,7 +45,7 @@ import urllib.request, urllib.parse, urllib.error
import copy import copy
import re import re
import time import time
from .types import *
from SOAPpy.Types import *


# SOAPpy modules # SOAPpy modules
from .Errors import * from .Errors import *
@@ -75,7 +75,7 @@ class anyType:
if self.__class__ == anyType: if self.__class__ == anyType:
raise Error("anyType can't be instantiated directly") raise Error("anyType can't be instantiated directly")


if type(name) in (ListType, TupleType):
if type(name) in (list, tuple):
self._ns, self._name = name self._ns, self._name = name
else: else:
self._ns = self._validURIs[0] self._ns = self._validURIs[0]
@@ -118,15 +118,15 @@ class anyType:
def _fixAttr(self, attr): def _fixAttr(self, attr):
if type(attr) in (StringType, UnicodeType): if type(attr) in (StringType, UnicodeType):
attr = (None, attr) attr = (None, attr)
elif type(attr) == ListType:
elif type(attr) == list:
attr = tuple(attr) attr = tuple(attr)
elif type(attr) != TupleType:
elif type(attr) != tuple:
raise AttributeError("invalid attribute type") raise AttributeError("invalid attribute type")


if len(attr) != 2: if len(attr) != 2:
raise AttributeError("invalid attribute length") raise AttributeError("invalid attribute length")


if type(attr[0]) not in (NoneType, StringType, UnicodeType):
if type(attr[0]) not in (type(None), str):
raise AttributeError("invalid attribute namespace URI type") raise AttributeError("invalid attribute namespace URI type")


return attr return attr
@@ -149,13 +149,13 @@ class anyType:


def _setAttrs(self, attrs): def _setAttrs(self, attrs):
if type(attrs) in (ListType, TupleType):
if type(attrs) in (list, tuple):
for i in range(0, len(attrs), 2): for i in range(0, len(attrs), 2):
self._setAttr(attrs[i], attrs[i + 1]) self._setAttr(attrs[i], attrs[i + 1])


return return


if type(attrs) == DictType:
if type(attrs) == dict:
d = attrs d = attrs
elif isinstance(attrs, anyType): elif isinstance(attrs, anyType):
d = attrs._attrs d = attrs._attrs
@@ -284,7 +284,7 @@ class decimalType(anyType):
if data == None: if data == None:
raise ValueError("must supply initial %s value" % self._type) raise ValueError("must supply initial %s value" % self._type)


if type(data) not in (IntType, LongType, FloatType):
if type(data) not in (int, LongType, FloatType):
raise Error("invalid %s value" % self._type) raise Error("invalid %s value" % self._type)


return data return data
@@ -294,7 +294,7 @@ class floatType(anyType):
if data == None: if data == None:
raise ValueError("must supply initial %s value" % self._type) raise ValueError("must supply initial %s value" % self._type)


if type(data) not in (IntType, LongType, FloatType) or \
if type(data) not in (int, LongType, FloatType) or \
data < -3.4028234663852886E+38 or \ data < -3.4028234663852886E+38 or \
data > 3.4028234663852886E+38: data > 3.4028234663852886E+38:
raise ValueError("invalid %s value: %s" % (self._type, repr(data))) raise ValueError("invalid %s value: %s" % (self._type, repr(data)))
@@ -309,7 +309,7 @@ class doubleType(anyType):
if data == None: if data == None:
raise ValueError("must supply initial %s value" % self._type) raise ValueError("must supply initial %s value" % self._type)


if type(data) not in (IntType, LongType, FloatType) or \
if type(data) not in (int, LongType, FloatType) or \
data < -1.7976931348623158E+308 or \ data < -1.7976931348623158E+308 or \
data > 1.7976931348623157E+308: data > 1.7976931348623157E+308:
raise ValueError("invalid %s value: %s" % (self._type, repr(data))) raise ValueError("invalid %s value: %s" % (self._type, repr(data)))
@@ -329,9 +329,9 @@ class durationType(anyType):
try: try:
# A tuple or a scalar is OK, but make them into a list # A tuple or a scalar is OK, but make them into a list


if type(data) == TupleType:
if type(data) == tuple:
data = list(data) data = list(data)
elif type(data) != ListType:
elif type(data) != list:
data = [data] data = [data]


if len(data) > 6: if len(data) > 6:
@@ -348,7 +348,7 @@ class durationType(anyType):
continue continue


if type(data[i]) not in \ if type(data[i]) not in \
(IntType, LongType, FloatType):
(int, LongType, FloatType):
raise Exception("element %d a bad type" % i) raise Exception("element %d a bad type" % i)


if data[i] and f == -1: if data[i] and f == -1:
@@ -433,13 +433,13 @@ class dateTimeType(anyType):
if data == None: if data == None:
data = time.time() data = time.time()


if (type(data) in (IntType, LongType)):
if (type(data) in (int, LongType)):
data = list(time.gmtime(data)[:6]) data = list(time.gmtime(data)[:6])
elif (type(data) == FloatType): elif (type(data) == FloatType):
f = data - int(data) f = data - int(data)
data = list(time.gmtime(int(data))[:6]) data = list(time.gmtime(int(data))[:6])
data[5] += f data[5] += f
elif type(data) in (ListType, TupleType):
elif type(data) in (list, tuple):
if len(data) < 6: if len(data) < 6:
raise Exception("not enough values") raise Exception("not enough values")
if len(data) > 9: if len(data) > 9:
@@ -477,13 +477,13 @@ class recurringInstantType(anyType):
try: try:
if data == None: if data == None:
data = list(time.gmtime(time.time())[:6]) data = list(time.gmtime(time.time())[:6])
if (type(data) in (IntType, LongType)):
if (type(data) in (int, LongType)):
data = list(time.gmtime(data)[:6]) data = list(time.gmtime(data)[:6])
elif (type(data) == FloatType): elif (type(data) == FloatType):
f = data - int(data) f = data - int(data)
data = list(time.gmtime(int(data))[:6]) data = list(time.gmtime(int(data))[:6])
data[5] += f data[5] += f
elif type(data) in (ListType, TupleType):
elif type(data) in (list, tuple):
if len(data) < 1: if len(data) < 1:
raise Exception("not enough values") raise Exception("not enough values")
if len(data) > 9: if len(data) > 9:
@@ -566,9 +566,9 @@ class timeType(anyType):
f = data - int(data) f = data - int(data)
data = list(time.gmtime(int(data))[3:6]) data = list(time.gmtime(int(data))[3:6])
data[2] += f data[2] += f
elif type(data) in (IntType, LongType):
elif type(data) in (int, LongType):
data = time.gmtime(data)[3:6] data = time.gmtime(data)[3:6]
elif type(data) in (ListType, TupleType):
elif type(data) in (list, tuple):
if len(data) == 9: if len(data) == 9:
data = data[3:6] data = data[3:6]
elif len(data) > 3: elif len(data) > 3:
@@ -610,9 +610,9 @@ class dateType(anyType):
try: try:
if data == None: if data == None:
data = time.gmtime(time.time())[0:3] data = time.gmtime(time.time())[0:3]
elif type(data) in (IntType, LongType, FloatType):
elif type(data) in (int, LongType, FloatType):
data = time.gmtime(data)[0:3] data = time.gmtime(data)[0:3]
elif type(data) in (ListType, TupleType):
elif type(data) in (list, tuple):
if len(data) == 9: if len(data) == 9:
data = data[0:3] data = data[0:3]
elif len(data) > 3: elif len(data) > 3:
@@ -653,9 +653,9 @@ class gYearMonthType(anyType):
try: try:
if data == None: if data == None:
data = time.gmtime(time.time())[0:2] data = time.gmtime(time.time())[0:2]
elif type(data) in (IntType, LongType, FloatType):
elif type(data) in (int, LongType, FloatType):
data = time.gmtime(data)[0:2] data = time.gmtime(data)[0:2]
elif type(data) in (ListType, TupleType):
elif type(data) in (list, tuple):
if len(data) == 9: if len(data) == 9:
data = data[0:2] data = data[0:2]
elif len(data) > 2: elif len(data) > 2:
@@ -696,10 +696,10 @@ class gYearType(anyType):
try: try:
if data == None: if data == None:
data = time.gmtime(time.time())[0:1] data = time.gmtime(time.time())[0:1]
elif type(data) in (IntType, LongType, FloatType):
elif type(data) in (int, LongType, FloatType):
data = [data] data = [data]


if type(data) in (ListType, TupleType):
if type(data) in (list, tuple):
if len(data) == 9: if len(data) == 9:
data = data[0:1] data = data[0:1]
elif len(data) < 1: elif len(data) < 1:
@@ -715,7 +715,7 @@ class gYearType(anyType):
raise Exception("not integral") raise Exception("not integral")


data = [s] data = [s]
elif type(data[0]) not in (IntType, LongType):
elif type(data[0]) not in (int, LongType):
raise Exception("bad type") raise Exception("bad type")
else: else:
raise Exception("invalid type") raise Exception("invalid type")
@@ -742,10 +742,10 @@ class centuryType(anyType):
try: try:
if data == None: if data == None:
data = time.gmtime(time.time())[0:1] / 100 data = time.gmtime(time.time())[0:1] / 100
elif type(data) in (IntType, LongType, FloatType):
elif type(data) in (int, LongType, FloatType):
data = [data] data = [data]


if type(data) in (ListType, TupleType):
if type(data) in (list, tuple):
if len(data) == 9: if len(data) == 9:
data = data[0:1] / 100 data = data[0:1] / 100
elif len(data) < 1: elif len(data) < 1:
@@ -761,7 +761,7 @@ class centuryType(anyType):
raise Exception("not integral") raise Exception("not integral")


data = [s] data = [s]
elif type(data[0]) not in (IntType, LongType):
elif type(data[0]) not in (int, LongType):
raise Exception("bad type") raise Exception("bad type")
else: else:
raise Exception("invalid type") raise Exception("invalid type")
@@ -791,9 +791,9 @@ class gMonthDayType(anyType):
try: try:
if data == None: if data == None:
data = time.gmtime(time.time())[1:3] data = time.gmtime(time.time())[1:3]
elif type(data) in (IntType, LongType, FloatType):
elif type(data) in (int, LongType, FloatType):
data = time.gmtime(data)[1:3] data = time.gmtime(data)[1:3]
elif type(data) in (ListType, TupleType):
elif type(data) in (list, tuple):
if len(data) == 9: if len(data) == 9:
data = data[0:2] data = data[0:2]
elif len(data) > 2: elif len(data) > 2:
@@ -832,10 +832,10 @@ class gMonthType(anyType):
try: try:
if data == None: if data == None:
data = time.gmtime(time.time())[1:2] data = time.gmtime(time.time())[1:2]
elif type(data) in (IntType, LongType, FloatType):
elif type(data) in (int, LongType, FloatType):
data = [data] data = [data]


if type(data) in (ListType, TupleType):
if type(data) in (list, tuple):
if len(data) == 9: if len(data) == 9:
data = data[1:2] data = data[1:2]
elif len(data) < 1: elif len(data) < 1:
@@ -851,7 +851,7 @@ class gMonthType(anyType):
raise Exception("not integral") raise Exception("not integral")


data = [s] data = [s]
elif type(data[0]) not in (IntType, LongType):
elif type(data[0]) not in (int, LongType):
raise Exception("bad type") raise Exception("bad type")


if data[0] < 1 or data[0] > 12: if data[0] < 1 or data[0] > 12:
@@ -879,10 +879,10 @@ class gDayType(anyType):
try: try:
if data == None: if data == None:
data = time.gmtime(time.time())[2:3] data = time.gmtime(time.time())[2:3]
elif type(data) in (IntType, LongType, FloatType):
elif type(data) in (int, LongType, FloatType):
data = [data] data = [data]


if type(data) in (ListType, TupleType):
if type(data) in (list, tuple):
if len(data) == 9: if len(data) == 9:
data = data[2:3] data = data[2:3]
elif len(data) < 1: elif len(data) < 1:
@@ -898,7 +898,7 @@ class gDayType(anyType):
raise Exception("not integral") raise Exception("not integral")


data = [s] data = [s]
elif type(data[0]) not in (IntType, LongType):
elif type(data[0]) not in (int, LongType):
raise Exception("bad type") raise Exception("bad type")


if data[0] < 1 or data[0] > 31: if data[0] < 1 or data[0] > 31:
@@ -1038,7 +1038,7 @@ class ENTITIESType(anyType):
if type(data) in (StringType, UnicodeType): if type(data) in (StringType, UnicodeType):
return (data,) return (data,)


if type(data) not in (ListType, TupleType) or \
if type(data) not in (list, tuple) or \
[x for x in data if type(x) not in (StringType, UnicodeType)]: [x for x in data if type(x) not in (StringType, UnicodeType)]:
raise AttributeError("invalid %s type" % self._type) raise AttributeError("invalid %s type" % self._type)


@@ -1055,7 +1055,7 @@ class integerType(anyType):
if data == None: if data == None:
raise ValueError("must supply initial %s value" % self._type) raise ValueError("must supply initial %s value" % self._type)


if type(data) not in (IntType, LongType):
if type(data) not in (int, LongType):
raise ValueError("invalid %s value" % self._type) raise ValueError("invalid %s value" % self._type)


return data return data
@@ -1067,7 +1067,7 @@ class nonPositiveIntegerType(anyType):
if data == None: if data == None:
raise ValueError("must supply initial %s value" % self._type) raise ValueError("must supply initial %s value" % self._type)


if type(data) not in (IntType, LongType) or data > 0:
if type(data) not in (int, LongType) or data > 0:
raise ValueError("invalid %s value" % self._type) raise ValueError("invalid %s value" % self._type)


return data return data
@@ -1085,7 +1085,7 @@ class negativeIntegerType(anyType):
if data == None: if data == None:
raise ValueError("must supply initial %s value" % self._type) raise ValueError("must supply initial %s value" % self._type)


if type(data) not in (IntType, LongType) or data >= 0:
if type(data) not in (int, LongType) or data >= 0:
raise ValueError("invalid %s value" % self._type) raise ValueError("invalid %s value" % self._type)


return data return data
@@ -1103,21 +1103,21 @@ class longType(anyType):
if data == None: if data == None:
raise ValueError("must supply initial %s value" % self._type) raise ValueError("must supply initial %s value" % self._type)


if type(data) not in (IntType, LongType) or \
if type(data) not in (int, LongType) or \
data < -9223372036854775808 or \ data < -9223372036854775808 or \
data > 9223372036854775807: data > 9223372036854775807:
raise ValueError("invalid %s value" % self._type) raise ValueError("invalid %s value" % self._type)


return data return data


class intType(anyType):
class int(anyType):
_validURIs = (NS.XSD2, NS.XSD3, NS.ENC) _validURIs = (NS.XSD2, NS.XSD3, NS.ENC)


def _checkValueSpace(self, data): def _checkValueSpace(self, data):
if data == None: if data == None:
raise ValueError("must supply initial %s value" % self._type) raise ValueError("must supply initial %s value" % self._type)


if type(data) not in (IntType, LongType) or \
if type(data) not in (int, LongType) or \
data < -2147483648 or \ data < -2147483648 or \
data > 2147483647: data > 2147483647:
raise ValueError("invalid %s value" % self._type) raise ValueError("invalid %s value" % self._type)
@@ -1131,7 +1131,7 @@ class shortType(anyType):
if data == None: if data == None:
raise ValueError("must supply initial %s value" % self._type) raise ValueError("must supply initial %s value" % self._type)


if type(data) not in (IntType, LongType) or \
if type(data) not in (int, LongType) or \
data < -32768 or \ data < -32768 or \
data > 32767: data > 32767:
raise ValueError("invalid %s value" % self._type) raise ValueError("invalid %s value" % self._type)
@@ -1145,7 +1145,7 @@ class byteType(anyType):
if data == None: if data == None:
raise ValueError("must supply initial %s value" % self._type) raise ValueError("must supply initial %s value" % self._type)


if type(data) not in (IntType, LongType) or \
if type(data) not in (int, LongType) or \
data < -128 or \ data < -128 or \
data > 127: data > 127:
raise ValueError("invalid %s value" % self._type) raise ValueError("invalid %s value" % self._type)
@@ -1159,7 +1159,7 @@ class nonNegativeIntegerType(anyType):
if data == None: if data == None:
raise ValueError("must supply initial %s value" % self._type) raise ValueError("must supply initial %s value" % self._type)


if type(data) not in (IntType, LongType) or data < 0:
if type(data) not in (int, LongType) or data < 0:
raise ValueError("invalid %s value" % self._type) raise ValueError("invalid %s value" % self._type)


return data return data
@@ -1177,21 +1177,21 @@ class unsignedLongType(anyType):
if data == None: if data == None:
raise ValueError("must supply initial %s value" % self._type) raise ValueError("must supply initial %s value" % self._type)


if type(data) not in (IntType, LongType) or \
if type(data) not in (int, LongType) or \
data < 0 or \ data < 0 or \
data > 18446744073709551615: data > 18446744073709551615:
raise ValueError("invalid %s value" % self._type) raise ValueError("invalid %s value" % self._type)


return data return data


class unsignedIntType(anyType):
class unsignedint(anyType):
_validURIs = (NS.XSD2, NS.XSD3, NS.ENC) _validURIs = (NS.XSD2, NS.XSD3, NS.ENC)


def _checkValueSpace(self, data): def _checkValueSpace(self, data):
if data == None: if data == None:
raise ValueError("must supply initial %s value" % self._type) raise ValueError("must supply initial %s value" % self._type)


if type(data) not in (IntType, LongType) or \
if type(data) not in (int, LongType) or \
data < 0 or \ data < 0 or \
data > 4294967295: data > 4294967295:
raise ValueError("invalid %s value" % self._type) raise ValueError("invalid %s value" % self._type)
@@ -1205,7 +1205,7 @@ class unsignedShortType(anyType):
if data == None: if data == None:
raise ValueError("must supply initial %s value" % self._type) raise ValueError("must supply initial %s value" % self._type)


if type(data) not in (IntType, LongType) or \
if type(data) not in (int, LongType) or \
data < 0 or \ data < 0 or \
data > 65535: data > 65535:
raise ValueError("invalid %s value" % self._type) raise ValueError("invalid %s value" % self._type)
@@ -1219,7 +1219,7 @@ class unsignedByteType(anyType):
if data == None: if data == None:
raise ValueError("must supply initial %s value" % self._type) raise ValueError("must supply initial %s value" % self._type)


if type(data) not in (IntType, LongType) or \
if type(data) not in (int, LongType) or \
data < 0 or \ data < 0 or \
data > 255: data > 255:
raise ValueError("invalid %s value" % self._type) raise ValueError("invalid %s value" % self._type)
@@ -1233,7 +1233,7 @@ class positiveIntegerType(anyType):
if data == None: if data == None:
raise ValueError("must supply initial %s value" % self._type) raise ValueError("must supply initial %s value" % self._type)


if type(data) not in (IntType, LongType) or data <= 0:
if type(data) not in (int, LongType) or data <= 0:
raise ValueError("invalid %s value" % self._type) raise ValueError("invalid %s value" % self._type)


return data return data
@@ -1254,7 +1254,7 @@ class compoundType(anyType):
anyType.__init__(self, data, name, typed, attrs) anyType.__init__(self, data, name, typed, attrs)
self._keyord = [] self._keyord = []


if type(data) == DictType:
if type(data) == dict:
self.__dict__.update(data) self.__dict__.update(data)


def _aslist(self, item=None): def _aslist(self, item=None):
@@ -1282,7 +1282,7 @@ class compoundType(anyType):


def __getitem__(self, item): def __getitem__(self, item):
if type(item) == IntType:
if not isinstance(item, str):
return self.__dict__[self._keyord[item]] return self.__dict__[self._keyord[item]]
else: else:
return getattr(self, item) return getattr(self, item)
@@ -1299,7 +1299,7 @@ class compoundType(anyType):
def _addItem(self, name, value, attrs = None): def _addItem(self, name, value, attrs = None):


if name in self._keyord: if name in self._keyord:
if type(self.__dict__[name]) != ListType:
if type(self.__dict__[name]) != list:
self.__dict__[name] = [self.__dict__[name]] self.__dict__[name] = [self.__dict__[name]]
self.__dict__[name].append(value) self.__dict__[name].append(value)
else: else:
@@ -1308,7 +1308,7 @@ class compoundType(anyType):
def _placeItem(self, name, value, pos, subpos = 0, attrs = None): def _placeItem(self, name, value, pos, subpos = 0, attrs = None):


if subpos == 0 and type(self.__dict__[name]) != ListType:
if subpos == 0 and type(self.__dict__[name]) != list:
self.__dict__[name] = value self.__dict__[name] = value
else: else:
self.__dict__[name][subpos] = value self.__dict__[name][subpos] = value
@@ -1328,7 +1328,7 @@ class compoundType(anyType):
except: except:
return default return default


if type(d) == ListType:
if type(d) == list:
return d return d
return [d] return [d]


@@ -1358,7 +1358,7 @@ class arrayType(collections.UserList, compoundType):
offset = 0, rank = None, asize = 0, elemsname = None): offset = 0, rank = None, asize = 0, elemsname = None):


if data: if data:
if type(data) not in (ListType, TupleType):
if type(data) not in (list, tuple):
raise Error("Data must be a sequence") raise Error("Data must be a sequence")


collections.UserList.__init__(self, data) collections.UserList.__init__(self, data)
@@ -1694,7 +1694,7 @@ def simplify(object, level=0):
if isPublic(k): if isPublic(k):
data[k] = simplify(data[k], level=level+1) data[k] = simplify(data[k], level=level+1)
return data return data
elif type(object)==DictType:
elif type(object)==dict:
for k in list(object.keys()): for k in list(object.keys()):
if isPublic(k): if isPublic(k):
object[k] = simplify(object[k]) object[k] = simplify(object[k])
@@ -1741,7 +1741,7 @@ def simplify_contents(object, level=0):
for k in list(data.keys()): for k in list(data.keys()):
if isPublic(k): if isPublic(k):
object[k] = simplify(data[k], level=level+1) object[k] = simplify(data[k], level=level+1)
elif type(object)==DictType:
elif type(object)==dict:
for k in list(object.keys()): for k in list(object.keys()):
if isPublic(k): if isPublic(k):
object[k] = simplify(object[k]) object[k] = simplify(object[k])


+ 1
- 1
src/SOAPpy/Utilities.py View File

@@ -39,7 +39,7 @@ from .version import __version__
import re import re
import string import string
import sys import sys
from .types import *
from SOAPpy.Types import *


# SOAPpy modules # SOAPpy modules
from .Errors import * from .Errors import *


+ 9
- 9
src/SOAPpy/__init__.py View File

@@ -2,14 +2,14 @@
ident = '$Id: __init__.py 541 2004-01-31 04:20:06Z warnes $' ident = '$Id: __init__.py 541 2004-01-31 04:20:06Z warnes $'
from .version import __version__ from .version import __version__


from .Client import *
from .Config import *
from .Errors import *
from .NS import *
from .Parser import *
from .SOAPBuilder import *
from .Server import *
from .types import *
from .Utilities import *
from SOAPpy.Client import *
from SOAPpy.Config import *
from SOAPpy.Errors import *
from SOAPpy.NS import *
from SOAPpy.Parser import *
from SOAPpy.SOAPBuilder import *
from SOAPpy.Server import *
from SOAPpy.Types import *
from SOAPpy.Utilities import *
import wstools import wstools
from . import WSDL from . import WSDL

Loading…
Cancel
Save