Skip to content

Commit acc8c31

Browse files
victor-ruronreiter
authored andcommitted
replaced suds with suds-py3
1 parent 44c1536 commit acc8c31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2178
-1943
lines changed

suds/__init__.py

+68-25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This program is free software; you can redistribute it and/or modify
22
# it under the terms of the (LGPL) GNU Lesser General Public License as
3-
# published by the Free Software Foundation; either version 3 of the
3+
# published by the Free Software Foundation; either version 3 of the
44
# License, or (at your option) any later version.
55
#
66
# This program is distributed in the hope that it will be useful,
@@ -19,36 +19,40 @@
1919
service proxy for Web Services.
2020
"""
2121

22-
import os
23-
import sys
22+
from .compat import basestring, unicode
2423

2524
#
2625
# Project properties
2726
#
2827

29-
__version__ = '0.4'
30-
__build__="GA R699-20100913"
28+
__version__ = '1.4.4.1'
29+
__build__ = "IN 20210108"
3130

3231
#
3332
# Exceptions
3433
#
3534

35+
3636
class MethodNotFound(Exception):
3737
def __init__(self, name):
3838
Exception.__init__(self, "Method not found: '%s'" % name)
39-
39+
40+
4041
class PortNotFound(Exception):
4142
def __init__(self, name):
4243
Exception.__init__(self, "Port not found: '%s'" % name)
43-
44+
45+
4446
class ServiceNotFound(Exception):
4547
def __init__(self, name):
4648
Exception.__init__(self, "Service not found: '%s'" % name)
47-
49+
50+
4851
class TypeNotFound(Exception):
4952
def __init__(self, name):
5053
Exception.__init__(self, "Type not found: '%s'" % tostr(name))
51-
54+
55+
5256
class BuildError(Exception):
5357
msg = \
5458
"""
@@ -58,51 +62,84 @@ class BuildError(Exception):
5862
Please open a ticket with a description of this error.
5963
Reason: %s
6064
"""
65+
6166
def __init__(self, name, exception):
6267
Exception.__init__(self, BuildError.msg % (name, exception))
63-
68+
69+
6470
class SoapHeadersNotPermitted(Exception):
6571
msg = \
6672
"""
6773
Method (%s) was invoked with SOAP headers. The WSDL does not
6874
define SOAP headers for this method. Retry without the soapheaders
6975
keyword argument.
7076
"""
77+
7178
def __init__(self, name):
7279
Exception.__init__(self, self.msg % name)
73-
80+
81+
82+
def smart_str(s, encoding='utf-8', errors='strict'):
83+
"""
84+
Returns a bytestring version of 's', encoded as specified in 'encoding'.
85+
86+
If strings_only is True, don't convert (some) non-string-like objects.
87+
88+
from django
89+
"""
90+
if not isinstance(s, basestring):
91+
try:
92+
return str(s)
93+
except UnicodeEncodeError:
94+
if isinstance(s, Exception):
95+
# An Exception subclass containing non-ASCII data that doesn't
96+
# know how to print itself properly. We shouldn't raise a
97+
# further exception.
98+
return ' '.join(smart_str(arg, encoding, errors) for arg in s)
99+
return unicode(s).encode(encoding, errors)
100+
elif isinstance(s, unicode):
101+
return s.encode(encoding, errors)
102+
elif s and encoding != 'utf-8':
103+
return s.decode('utf-8', errors).encode(encoding, errors)
104+
else:
105+
return s
106+
107+
74108
class WebFault(Exception):
75109
def __init__(self, fault, document):
76110
if hasattr(fault, 'faultstring'):
77-
Exception.__init__(self, "Server raised fault: '%s'" % fault.faultstring)
111+
Exception.__init__(self, smart_str("Server raised fault: '%s'" % fault.faultstring))
78112
self.fault = fault
79113
self.document = document
80114

81115
#
82116
# Logging
83117
#
84118

119+
85120
class Repr:
86121
def __init__(self, x):
87122
self.x = x
123+
88124
def __str__(self):
89-
return repr(self.x)
125+
return repr(self.x)
90126

91127
#
92128
# Utility
93129
#
94130

131+
95132
def tostr(object, encoding=None):
96133
""" get a unicode safe string representation of an object """
97-
if isinstance(object, str):
134+
if isinstance(object, basestring):
98135
if encoding is None:
99136
return object
100137
else:
101138
return object.encode(encoding)
102139
if isinstance(object, tuple):
103140
s = ['(']
104141
for item in object:
105-
if isinstance(item, str):
142+
if isinstance(item, basestring):
106143
s.append(item)
107144
else:
108145
s.append(tostr(item))
@@ -112,7 +149,7 @@ def tostr(object, encoding=None):
112149
if isinstance(object, list):
113150
s = ['[']
114151
for item in object:
115-
if isinstance(item, str):
152+
if isinstance(item, basestring):
116153
s.append(item)
117154
else:
118155
s.append(tostr(item))
@@ -121,34 +158,40 @@ def tostr(object, encoding=None):
121158
return ''.join(s)
122159
if isinstance(object, dict):
123160
s = ['{']
124-
for item in list(object.items()):
125-
if isinstance(item[0], str):
161+
for item in object.items():
162+
if isinstance(item[0], basestring):
126163
s.append(item[0])
127164
else:
128165
s.append(tostr(item[0]))
129166
s.append(' = ')
130-
if isinstance(item[1], str):
167+
if isinstance(item[1], basestring):
131168
s.append(item[1])
132169
else:
133170
s.append(tostr(item[1]))
134171
s.append(', ')
135172
s.append('}')
136173
return ''.join(s)
137174
try:
138-
return str(object)
175+
return unicode(object)
139176
except:
140177
return str(object)
141-
178+
179+
142180
class null:
143181
"""
144182
The I{null} object.
145183
Used to pass NULL for optional XML nodes.
146184
"""
147185
pass
148-
186+
187+
class Object(object):
188+
"""
189+
The python 3 base Object
190+
"""
191+
pass
192+
149193
def objid(obj):
150-
return obj.__class__.__name__\
151-
+':'+hex(id(obj))
194+
return obj.__class__.__name__ + ':' + hex(id(obj))
152195

153196

154-
from . import client
197+
from .client import Client

suds/bindings/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This program is free software; you can redistribute it and/or modify
22
# it under the terms of the (LGPL) GNU Lesser General Public License as
3-
# published by the Free Software Foundation; either version 3 of the
3+
# published by the Free Software Foundation; either version 3 of the
44
# License, or (at your option) any later version.
55
#
66
# This program is distributed in the hope that it will be useful,
@@ -17,4 +17,4 @@
1717
"""
1818
Provides modules containing classes to support Web Services (SOAP)
1919
bindings.
20-
"""
20+
"""

0 commit comments

Comments
 (0)