Skip to content

Commit

Permalink
Merge pull request #2 from funkybob/tidy-up
Browse files Browse the repository at this point in the history
Tidy up
  • Loading branch information
cackharot committed Jul 12, 2014
2 parents f1bf033 + 0ce789f commit ac18f97
Show file tree
Hide file tree
Showing 57 changed files with 1,517 additions and 1,509 deletions.
42 changes: 26 additions & 16 deletions suds/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This program is free software; you can redistribute it and/or modify
# it under the terms of the (LGPL) GNU Lesser General Public License as
# published by the Free Software Foundation; either version 3 of the
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
Expand All @@ -19,36 +19,40 @@
service proxy for Web Services.
"""

import os
import sys
from .compat import basestring, unicode

#
# Project properties
#

__version__ = '1.0.0.0'
__build__="IN 20140319"
__build__ = "IN 20140319"

#
# Exceptions
#


class MethodNotFound(Exception):
def __init__(self, name):
Exception.__init__(self, "Method not found: '%s'" % name)



class PortNotFound(Exception):
def __init__(self, name):
Exception.__init__(self, "Port not found: '%s'" % name)



class ServiceNotFound(Exception):
def __init__(self, name):
Exception.__init__(self, "Service not found: '%s'" % name)



class TypeNotFound(Exception):
def __init__(self, name):
Exception.__init__(self, "Type not found: '%s'" % tostr(name))



class BuildError(Exception):
msg = \
"""
Expand All @@ -58,16 +62,19 @@ class BuildError(Exception):
Please open a ticket with a description of this error.
Reason: %s
"""

def __init__(self, name, exception):
Exception.__init__(self, BuildError.msg % (name, exception))



class SoapHeadersNotPermitted(Exception):
msg = \
"""
Method (%s) was invoked with SOAP headers. The WSDL does not
define SOAP headers for this method. Retry without the soapheaders
keyword argument.
"""

def __init__(self, name):
Exception.__init__(self, self.msg % name)

Expand All @@ -88,7 +95,7 @@ def smart_str(s, encoding='utf-8', errors='strict'):
# An Exception subclass containing non-ASCII data that doesn't
# know how to print itself properly. We shouldn't raise a
# further exception.
return ' '.join([smart_str(arg, encoding, errors) for arg in s])
return ' '.join(smart_str(arg, encoding, errors) for arg in s)
return unicode(s).encode(encoding, errors)
elif isinstance(s, unicode):
return s.encode(encoding, errors)
Expand All @@ -109,16 +116,19 @@ def __init__(self, fault, document):
# Logging
#


class Repr:
def __init__(self, x):
self.x = x

def __str__(self):
return repr(self.x)
return repr(self.x)

#
# Utility
#


def tostr(object, encoding=None):
""" get a unicode safe string representation of an object """
if isinstance(object, basestring):
Expand Down Expand Up @@ -165,18 +175,18 @@ def tostr(object, encoding=None):
return unicode(object)
except:
return str(object)



class null:
"""
The I{null} object.
Used to pass NULL for optional XML nodes.
"""
pass



def objid(obj):
return obj.__class__.__name__\
+':'+hex(id(obj))
return obj.__class__.__name__ + ':' + hex(id(obj))

basestring = unicode = str

from .client import Client
4 changes: 2 additions & 2 deletions suds/bindings/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This program is free software; you can redistribute it and/or modify
# it under the terms of the (LGPL) GNU Lesser General Public License as
# published by the Free Software Foundation; either version 3 of the
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
Expand All @@ -17,4 +17,4 @@
"""
Provides modules containing classes to support Web Services (SOAP)
bindings.
"""
"""
Loading

0 comments on commit ac18f97

Please sign in to comment.