diff --git a/.project b/.project index c0eaac0..3022cbd 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - suds + txsuds diff --git a/.pydevproject b/.pydevproject index 0870f5a..396cd32 100644 --- a/.pydevproject +++ b/.pydevproject @@ -4,9 +4,9 @@ python 2.6 -/suds -/suds/suds -/suds/tests +/txsuds +/txsuds/suds +/txsuds/tests diff --git a/makefile b/makefile index 32a3f9e..a44cb4d 100644 --- a/makefile +++ b/makefile @@ -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, @@ -49,11 +49,11 @@ rdocs : docs docs : rm -rf doc rm -f /tmp/$(DOCTAR) - epydoc -vo doc `find suds -name "*.py"` + epydoc -vo doc `find txsuds -name "*.py"` tar czvf /tmp/$(DOCTAR) doc pdf : - epydoc -vo doc --pdf `find suds -name \*.py` + epydoc -vo doc --pdf `find txsuds -name \*.py` mv doc/api.pdf doc/sudsapi.pdf clean : diff --git a/sdist b/sdist index a1239e9..6502130 100755 --- a/sdist +++ b/sdist @@ -1,7 +1,7 @@ #!/bin/bash # 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, @@ -15,7 +15,7 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # written by: Jeff Ortel ( jortel@redhat.com ) -product="suds" +product="txsuds" version=`python -c "import $product; print $product.__version__"` if [ $1 ] diff --git a/setup.py b/setup.py index 659e123..59916bd 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ # # 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, @@ -16,13 +16,12 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # written by: Jeff Ortel ( jortel@redhat.com ) -import sys -import suds +import txsuds from setuptools import setup, find_packages setup( - name="suds", - version=suds.__version__, + name="txsuds", + version=txsuds.__version__, description="Lightweight SOAP client", author="Jeff Ortel", author_email="jortel@redhat.com", diff --git a/tests/axis1.py b/tests/axis1.py index 5c72867..4e79d3e 100644 --- a/tests/axis1.py +++ b/tests/axis1.py @@ -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, @@ -21,15 +21,13 @@ import sys sys.path.append('../') -import logging import traceback as tb -import suds.metrics as metrics from tests import * -from suds import WebFault -from suds.client import Client -from suds.sudsobject import Object -from suds.transport.https import HttpAuthenticated -from suds.plugin import * +from txsuds import WebFault +from txsuds.client import Client +from txsuds.sudsobject import Object +from txsuds.transport.https import HttpAuthenticated +from txsuds.plugin import * errors = 0 @@ -43,34 +41,34 @@ class MyInitPlugin(InitPlugin): def initialized(self, context): print 'PLUGIN (init): initialized: ctx=%s' % context.__dict__ - + class MyDocumentPlugin(DocumentPlugin): - + def loaded(self, context): print 'PLUGIN (document): loaded: ctx=%s' % context.__dict__ def parsed(self, context): print 'PLUGIN (document): parsed: ctx=%s' % context.__dict__ - + class MyMessagePlugin(MessagePlugin): - + def marshalled(self, context): print 'PLUGIN (message): marshalled: ctx=%s' % context.__dict__ - + def sending(self, context): print 'PLUGIN (message): sending: ctx=%s' % context.__dict__ def received(self, context): print 'PLUGIN (message): received: ctx=%s' % context.__dict__ - + def parsed(self, context): print 'PLUGIN (message): parsed: ctx=%s' % context.__dict__ - + def unmarshalled(self, context): print 'PLUGIN: (massage): unmarshalled: ctx=%s' % context.__dict__ - - + + myplugins = ( MyInitPlugin(), MyDocumentPlugin(), @@ -81,7 +79,7 @@ def unmarshalled(self, context): def start(url): global errors - print '\n________________________________________________________________\n' + print '\n________________________________________________________________\n' print 'Test @ ( %s )\nerrors = %d\n' % (url, errors) try: @@ -137,7 +135,7 @@ def start(url): print 'addPersion()' result = client.service.addPerson(person) print '\nreply(\n%s\n)\n' % str(result) - + # # Async # @@ -149,7 +147,7 @@ def start(url): error.httpcode = '500' client.options.nosend=False # request.failed(error) - + # # # create a new name object used to update the person @@ -182,7 +180,7 @@ def start(url): errors += 1 print e tb.print_exc() - + try: url = 'http://localhost:8081/axis/services/basic-rpc-encoded?wsdl' start(url) @@ -245,7 +243,7 @@ def start(url): errors += 1 print e tb.print_exc() - + try: print "echo(' this is cool ')" result = client.service.echo('this is cool') @@ -261,7 +259,7 @@ def start(url): errors += 1 print e tb.print_exc() - + try: print 'hello()' result = client.service.hello() @@ -326,7 +324,7 @@ def start(url): tb.print_exc() try: - print 'testExceptions()' + print 'testExceptions()' result = client.service.throwException() print '\nreply( %s )\n' % tostr(result) raise Exception('Fault expected and not raised') @@ -353,5 +351,5 @@ def start(url): errors += 1 print e tb.print_exc() - + print '\nFinished: errors=%d' % errors diff --git a/tests/axis2.py b/tests/axis2.py index 8ed0bdd..ba66024 100644 --- a/tests/axis2.py +++ b/tests/axis2.py @@ -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, @@ -17,13 +17,11 @@ import sys sys.path.append('../') -import logging -import traceback as tb -import suds.metrics as metrics from tests import * -from suds import * -from suds.client import Client +from txsuds import * +from txsuds.client import Client from datetime import datetime +from twisted.internet import defer errors = 0 @@ -32,7 +30,7 @@ #logging.getLogger('suds.client').setLevel(logging.DEBUG) url = 'http://localhost:8080/axis2/services/BasicService?wsdl' - + print 'url=%s' % url # @@ -40,6 +38,15 @@ # client = Client(url) + +@defer.inlineCallbacks +def connect(): + yield client.connect() +print 'connecting...', +connect() +print 'connected' + + # # print the service (introspection) # @@ -200,7 +207,7 @@ print '\nreply( %s )\n' % tostr(result) except Exception, e: print e - + # # test faults # diff --git a/tests/builtin.py b/tests/builtin.py index ca6c2e6..1e217dd 100644 --- a/tests/builtin.py +++ b/tests/builtin.py @@ -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, @@ -17,8 +17,7 @@ import sys sys.path.append('../') import unittest -from suds.sax.date import Timezone as Tz -from suds.xsd.sxbuiltin import * +from txsuds.xsd.sxbuiltin import * from unittest import TestCase from tests import * @@ -28,28 +27,33 @@ class Date(XDate): def __init__(self): pass + + class Time(XTime): def __init__(self): pass + + class DateTime(XDateTime): def __init__(self): pass - + + class DateTest(TestCase): - + def testSimple(self): ref = dt.date(1941, 12, 7) s = '%.4d-%.2d-%.2d' % (ref.year, ref.month, ref.day) xdate = Date() d = xdate.translate(s) self.assertEqual(d, ref) - + def testNegativeTimezone(self): self.equalsTimezone(-6) - + def testPositiveTimezone(self): self.equalsTimezone(6) - + def testUtcTimezone(self): Timezone.LOCAL = 0 ref = dt.date(1941, 12, 7) @@ -57,7 +61,7 @@ def testUtcTimezone(self): xdate = Date() d = xdate.translate(s) self.assertEqual(d, ref) - + def equalsTimezone(self, tz): Timezone.LOCAL = tz ref = dt.date(1941, 12, 7) @@ -67,7 +71,6 @@ def equalsTimezone(self, tz): self.assertEqual(d, ref) - class TimeTest(TestCase): def testSimple(self): @@ -76,34 +79,34 @@ def testSimple(self): xtime = Time() t = xtime.translate(s) self.assertEqual(t, ref) - + def testSimpleWithShortMicrosecond(self): ref = dt.time(10, 30, 22, 34) s = '%.2d:%.2d:%.2d.%4.d' % (ref.hour, ref.minute, ref.second, ref.microsecond) xtime = Time() t = xtime.translate(s) self.assertEqual(t, ref) - + def testSimpleWithMicrosecond(self): ref = dt.time(10, 30, 22, 999999) s = '%.2d:%.2d:%.2d.%4.d' % (ref.hour, ref.minute, ref.second, ref.microsecond) xtime = Time() t = xtime.translate(s) self.assertEqual(t, ref) - + def testSimpleWithLongMicrosecond(self): ref = dt.time(10, 30, 22, 999999) s = '%.2d:%.2d:%.2d.%4.d' % (ref.hour, ref.minute, ref.second, int('999999999')) xtime = Time() t = xtime.translate(s) self.assertEqual(t, ref) - + def testPositiveTimezone(self): self.equalsTimezone(6) - + def testNegativeTimezone(self): self.equalsTimezone(-6) - + def testUtcTimezone(self): Timezone.LOCAL = 0 ref = dt.time(10, 30, 22) @@ -111,7 +114,7 @@ def testUtcTimezone(self): xtime = Time() t = xtime.translate(s) self.assertEqual(t, ref) - + def equalsTimezone(self, tz): Timezone.LOCAL = tz ref = dt.time(10, 30, 22) @@ -119,77 +122,77 @@ def equalsTimezone(self, tz): xtime = Time() t = xtime.translate(s) self.assertEqual(t, ref) - + def testConvertNegativeToGreaterNegative(self): Timezone.LOCAL = -6 ref = dt.time(10, 30, 22) s = self.strTime(ref.hour, ref.minute, ref.second, -5) xtime = Time() t = xtime.translate(s) - self.assertEqual(ref.hour-1, t.hour) + self.assertEqual(ref.hour - 1, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertNegativeToLesserNegative(self): Timezone.LOCAL = -5 ref = dt.time(10, 30, 22) s = self.strTime(ref.hour, ref.minute, ref.second, -6) xtime = Time() t = xtime.translate(s) - self.assertEqual(ref.hour+1, t.hour) + self.assertEqual(ref.hour + 1, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertPositiveToGreaterPositive(self): Timezone.LOCAL = 3 ref = dt.time(10, 30, 22) s = self.strTime(ref.hour, ref.minute, ref.second, 2) xtime = Time() t = xtime.translate(s) - self.assertEqual(ref.hour+1, t.hour) + self.assertEqual(ref.hour + 1, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertPositiveToLesserPositive(self): Timezone.LOCAL = 2 ref = dt.time(10, 30, 22) s = self.strTime(ref.hour, ref.minute, ref.second, 3) xtime = Time() t = xtime.translate(s) - self.assertEqual(ref.hour-1, t.hour) + self.assertEqual(ref.hour - 1, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertPositiveToNegative(self): Timezone.LOCAL = -6 ref = dt.time(10, 30, 22) s = self.strTime(ref.hour, ref.minute, ref.second, 3) xtime = Time() t = xtime.translate(s) - self.assertEqual(ref.hour-9, t.hour) + self.assertEqual(ref.hour - 9, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertNegativeToPositive(self): Timezone.LOCAL = 3 ref = dt.time(10, 30, 22) s = self.strTime(ref.hour, ref.minute, ref.second, -6) xtime = Time() t = xtime.translate(s) - self.assertEqual(ref.hour+9, t.hour) + self.assertEqual(ref.hour + 9, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertNegativeToUtc(self): Timezone.LOCAL = 0 ref = dt.time(10, 30, 22) s = self.strTime(ref.hour, ref.minute, ref.second, -6) xtime = Time() t = xtime.translate(s) - self.assertEqual(ref.hour+6, t.hour) + self.assertEqual(ref.hour + 6, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertPositiveToUtc(self): Timezone.LOCAL = 0 ref = dt.time(10, 30, 22) @@ -199,7 +202,7 @@ def testConvertPositiveToUtc(self): self.assertEqual(ref.hour-3, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertUtcToPositive(self): Timezone.LOCAL = 3 ref = dt.time(10, 30, 22) @@ -209,7 +212,7 @@ def testConvertUtcToPositive(self): self.assertEqual(ref.hour+3, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertUtcToNegative(self): Timezone.LOCAL = -6 ref = dt.time(10, 30, 22) @@ -219,7 +222,7 @@ def testConvertUtcToNegative(self): self.assertEqual(ref.hour-6, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def strTime(self, h, m, s, offset): return '%.2d:%.2d:%.2d%+.2d:00' % (h, m, s, offset) @@ -230,62 +233,62 @@ def testSimple(self): ref = dt.datetime(1941, 12, 7, 10, 30, 22) s = '%.4d-%.2d-%.2dT%.2d:%.2d:%.2d' \ % (ref.year, - ref.month, - ref.day, - ref.hour, - ref.minute, + ref.month, + ref.day, + ref.hour, + ref.minute, ref.second) xdt = DateTime() t = xdt.translate(s) self.assertEqual(t, ref) - + def testOverflow(self): ref = dt.datetime(1, 1, 1, 0, 0, 0) s = '%.4d-%.2d-%.2dT%.2d:%.2d:%.2dZ' \ % (ref.year, - ref.month, - ref.day, - ref.hour, - ref.minute, + ref.month, + ref.day, + ref.hour, + ref.minute, ref.second) xdt = DateTime() t = xdt.translate(s) self.assertEqual(t, ref) - + def testSimpleWithMicrosecond(self): ref = dt.datetime(1941, 12, 7, 10, 30, 22, 454) s = '%.4d-%.2d-%.2dT%.2d:%.2d:%.2d.%.4d' \ - % (ref.year, - ref.month, - ref.day, - ref.hour, - ref.minute, - ref.second, + % (ref.year, + ref.month, + ref.day, + ref.hour, + ref.minute, + ref.second, ref.microsecond) xdt = DateTime() t = xdt.translate(s) self.assertEqual(t, ref) - + def testPositiveTimezone(self): self.equalsTimezone(6) - + def testNegativeTimezone(self): self.equalsTimezone(-6) - + def testUtcTimezone(self): Timezone.LOCAL = 0 ref = dt.datetime(1941, 12, 7, 10, 30, 22) s = '%.4d-%.2d-%.2dT%.2d:%.2d:%.2d' \ % (ref.year, - ref.month, - ref.day, - ref.hour, - ref.minute, + ref.month, + ref.day, + ref.hour, + ref.minute, ref.second) xdt = DateTime() t = xdt.translate(s) self.assertEqual(t, ref) - + def equalsTimezone(self, tz): Timezone.LOCAL = tz ref = dt.datetime(1941, 12, 7, 10, 30, 22) @@ -300,7 +303,7 @@ def equalsTimezone(self, tz): xdt = DateTime() t = xdt.translate(s) self.assertEqual(t, ref) - + def testConvertNegativeToGreaterNegative(self): Timezone.LOCAL = -6 ref = dt.datetime(1941, 12, 7, 10, 30, 22) @@ -320,7 +323,7 @@ def testConvertNegativeToGreaterNegative(self): self.assertEqual(ref.hour-1, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertNegativeToLesserNegative(self): Timezone.LOCAL = -5 ref = dt.datetime(1941, 12, 7, 10, 30, 22) @@ -340,7 +343,7 @@ def testConvertNegativeToLesserNegative(self): self.assertEqual(ref.hour+1, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertPositiveToGreaterPositive(self): Timezone.LOCAL = 3 ref = dt.datetime(1941, 12, 7, 10, 30, 22) @@ -360,7 +363,7 @@ def testConvertPositiveToGreaterPositive(self): self.assertEqual(ref.hour+1, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertPositiveToLesserPositive(self): Timezone.LOCAL = 2 ref = dt.datetime(1941, 12, 7, 10, 30, 22) @@ -380,7 +383,7 @@ def testConvertPositiveToLesserPositive(self): self.assertEqual(ref.hour-1, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertPositiveToNegative(self): Timezone.LOCAL = -6 ref = dt.datetime(1941, 12, 7, 10, 30, 22) @@ -400,7 +403,7 @@ def testConvertPositiveToNegative(self): self.assertEqual(ref.hour-9, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertNegativeToPositive(self): Timezone.LOCAL = 3 ref = dt.datetime(1941, 12, 7, 10, 30, 22) @@ -420,7 +423,7 @@ def testConvertNegativeToPositive(self): self.assertEqual(ref.hour+9, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertNegativeToUtc(self): Timezone.LOCAL = 0 ref = dt.datetime(1941, 12, 7, 10, 30, 22) @@ -440,7 +443,7 @@ def testConvertNegativeToUtc(self): self.assertEqual(ref.hour+6, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertPositiveToUtc(self): Timezone.LOCAL = 0 ref = dt.datetime(1941, 12, 7, 10, 30, 22) @@ -460,16 +463,16 @@ def testConvertPositiveToUtc(self): self.assertEqual(ref.hour-3, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertUtcToPositive(self): Timezone.LOCAL = 3 ref = dt.datetime(1941, 12, 7, 10, 30, 22) s = '%.4d-%.2d-%.2dT%.2d:%.2d:%.2dZ' \ % (ref.year, - ref.month, - ref.day, - ref.hour, - ref.minute, + ref.month, + ref.day, + ref.hour, + ref.minute, ref.second) xdt = DateTime() t = xdt.translate(s) @@ -479,16 +482,16 @@ def testConvertUtcToPositive(self): self.assertEqual(ref.hour+3, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertUtcToNegative(self): Timezone.LOCAL = -6 ref = dt.datetime(1941, 12, 7, 10, 30, 22) s = '%.4d-%.2d-%.2dT%.2d:%.2d:%.2dZ' \ % (ref.year, - ref.month, - ref.day, - ref.hour, - ref.minute, + ref.month, + ref.day, + ref.hour, + ref.minute, ref.second) xdt = DateTime() t = xdt.translate(s) @@ -498,7 +501,7 @@ def testConvertUtcToNegative(self): self.assertEqual(ref.hour-6, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertNegativeToGreaterNegativeAndPreviousDay(self): Timezone.LOCAL = -6 ref = dt.datetime(1941, 12, 7, 0, 30, 22) @@ -518,7 +521,7 @@ def testConvertNegativeToGreaterNegativeAndPreviousDay(self): self.assertEqual(23, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def testConvertNegativeToLesserNegativeAndNextDay(self): Timezone.LOCAL = -5 ref = dt.datetime(1941, 12, 7, 23, 30, 22) @@ -538,12 +541,12 @@ def testConvertNegativeToLesserNegativeAndNextDay(self): self.assertEqual(0, t.hour) self.assertEqual(ref.minute, t.minute) self.assertEqual(ref.second, t.second) - + def strDateTime(self, Y, M, D, h, m, s, offset): s = '%.4d-%.2d-%.2dT%.2d:%.2d:%.2d%+.2d:00' \ % (Y, M, D, h, m, s, offset) return s - + if __name__ == '__main__': unittest.main() diff --git a/tests/jasper.py b/tests/jasper.py index 79389a1..19e3863 100644 --- a/tests/jasper.py +++ b/tests/jasper.py @@ -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, @@ -17,14 +17,10 @@ import sys sys.path.append('../') -import logging -import traceback as tb -import urllib2 -import suds.metrics as metrics import traceback as tb from tests import * -from suds import WebFault -from suds.client import Client +from txsuds import WebFault +from txsuds.client import Client errors = 0 @@ -32,10 +28,11 @@ #logging.getLogger('suds.client').setLevel(logging.DEBUG) + def start(url): - print '\n________________________________________________________________\n' + print '\n________________________________________________________________\n' print 'Test @ ( %s )' % url - + try: url = 'http://localhost:9090/jasperserver-pro/services/repository?wsdl' start(url) diff --git a/tests/public.py b/tests/public.py index 5132c7f..1296ca2 100644 --- a/tests/public.py +++ b/tests/public.py @@ -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, @@ -17,12 +17,11 @@ import sys sys.path.append('../') -import logging import traceback as tb import suds.metrics as metrics from tests import * -from suds import WebFault -from suds.client import Client +from txsuds import WebFault +from txsuds.client import Client errors = 0 @@ -35,7 +34,7 @@ def start(url): global errors - print '\n________________________________________________________________\n' + print '\n________________________________________________________________\n' print 'Test @ ( %s ) %d' % (url, errors) try: @@ -74,11 +73,11 @@ def start(url): errors += 1 print f print f.fault -except Exception, e: +except Exception, e: errors += 1 print e tb.print_exc() - + try: url = 'http://jira.atlassian.com/rpc/soap/jirasoapservice-v2?wsdl' start(url) @@ -92,11 +91,11 @@ def start(url): errors += 1 print f print f.fault -except Exception, e: +except Exception, e: errors += 1 print e tb.print_exc() - + try: url = 'http://jira.atlassian.com/rpc/soap/jirasoapservice-v2?wsdl' start(url+' ** cloned **') @@ -110,11 +109,11 @@ def start(url): errors += 1 print f print f.fault -except Exception, e: +except Exception, e: errors += 1 print e tb.print_exc() - + try: url = ' http://www.boyzoid.com/comp/randomQuote.cfc?wsdl ' start(url) @@ -129,7 +128,7 @@ def start(url): errors += 1 print e tb.print_exc() - + try: url = 'http://www.zenfolio.com/zf/api/zfapi.asmx?wsdl' start(url) @@ -149,7 +148,7 @@ def start(url): errors += 1 print e tb.print_exc() - + try: url = 'http://cert.synxis.com/interface/ChannelConnect.asmx?WSDL' start(url) @@ -247,7 +246,7 @@ def start(url): errors += 1 print e tb.print_exc() - + try: url = "http://arcweb.esri.com/services/v2/RouteFinder.wsdl" start(url) diff --git a/tests/rhq.py b/tests/rhq.py index 2b755d1..9b6e4bf 100644 --- a/tests/rhq.py +++ b/tests/rhq.py @@ -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, @@ -24,10 +24,9 @@ import logging import traceback as tb -import suds.metrics as metrics from tests import * -from suds import null, WebFault -from suds.client import Client +from txsuds import WebFault +from txsuds.client import Client errors = 0 @@ -41,14 +40,14 @@ def start(url): global errors - print '\n________________________________________________________________\n' + print '\n________________________________________________________________\n' print 'Test @ ( %s ) %d' % (url, errors) def rhqTest(): - + global errors - + url = 'http://localhost.localdomain:7080/rhq-rhq-enterprise-server-ejb3/WebservicesManagerBean?wsdl' start(url) client = Client(url) @@ -93,7 +92,7 @@ def rhqTest(): person.phone.append(phoneB) person.pet.append(dog) person.pet.append(cat) - print person + print person # # addPerson() # @@ -124,7 +123,7 @@ def rhqTest(): errors += 1 print e tb.print_exc() - + try: print "echo('this is cool')" result = client.service.echo('this is cool') @@ -140,7 +139,7 @@ def rhqTest(): errors += 1 print e tb.print_exc() - + try: print 'hello()' result = client.service.hello() @@ -180,7 +179,7 @@ def rhqTest(): errors += 1 print e tb.print_exc() - + try: s = 'hello' for n in range(0, 3): @@ -198,9 +197,9 @@ def rhqTest(): errors += 1 print e tb.print_exc() - + try: - print 'testExceptions()' + print 'testExceptions()' result = client.service.testExceptions() print '\nreply( %s )\n' % tostr(result) raise Exception('Fault expected and not raised') @@ -213,7 +212,7 @@ def rhqTest(): print e tb.print_exc() - + if __name__ == '__main__': errors = 0 rhqTest() diff --git a/tests/saxenc.py b/tests/saxenc.py index e88e335..73d743d 100644 --- a/tests/saxenc.py +++ b/tests/saxenc.py @@ -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, @@ -18,8 +18,9 @@ # sax encoding/decoding test. # -from suds.sax.element import Element -from suds.sax.parser import Parser +from txsuds.sax.element import Element +from txsuds.sax.parser import Parser + def basic(): xml = "Me && <b>my</b> shadow's <i>dog</i> love to 'play' and sing "la,la,la";" @@ -43,6 +44,7 @@ def basic(): j.prune() print j + def cdata(): xml = 'This is my &<tag>]]>' p = Parser() @@ -51,6 +53,7 @@ def cdata(): a = d.root() print a.getText() + if __name__ == '__main__': #basic() cdata() diff --git a/tests/test_twisted.py b/tests/test_twisted.py index c799cf0..a92370c 100644 --- a/tests/test_twisted.py +++ b/tests/test_twisted.py @@ -1,40 +1,35 @@ import sys sys.path.append('../') -import logging import traceback as tb -import suds.metrics as metrics from tests import * -from suds import WebFault -from suds.client import Client +from txsuds import WebFault +from txsuds.client import Client from twisted.internet import reactor from twisted.internet import defer setup_logging() -#logging.getLogger('suds.client').setLevel(logging.DEBUG) -#logging.getLogger('suds.metrics').setLevel(logging.DEBUG) -#logging.getLogger('suds').setLevel(logging.DEBUG) @defer.inlineCallbacks def main(): - try: - url = 'https://sec.neurofuzz-software.com/paos/genSSHA-SOAP.php?wsdl' - print 'Test @ ( %s )' % (url) - client = Client(url) - yield client.connect() - print client - res = yield client.service.genSSHA('hello', 'sha1') - print res - except WebFault, f: - print f - print f.fault - except Exception, e: - print e - tb.print_exc() + try: + url = 'https://sec.neurofuzz-software.com/paos/genSSHA-SOAP.php?wsdl' + print 'Test @ ( %s )' % (url) + client = Client(url) + yield client.connect() + print client + res = yield client.service.genSSHA('hello', 'sha1') + print res + except WebFault, f: + print f + print f.fault + except Exception, e: + print e + tb.print_exc() - print '\nFinished' - reactor.stop() + print '\nFinished' + reactor.stop() reactor.callLater(0, main) diff --git a/suds/__init__.py b/txsuds/__init__.py similarity index 95% rename from suds/__init__.py rename to txsuds/__init__.py index 73e64e2..14b7400 100644 --- a/suds/__init__.py +++ b/txsuds/__init__.py @@ -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, @@ -19,36 +19,39 @@ service proxy for Web Services. """ -import os -import sys # # Project properties # __version__ = '0.4.1' -__build__="(beta) R705-20101207" +__build__ = "(beta) R705-20101207" # # 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 = \ """ @@ -58,9 +61,11 @@ 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 = \ """ @@ -68,9 +73,11 @@ class SoapHeadersNotPermitted(Exception): define SOAP headers for this method. Retry without the soapheaders keyword argument. """ + def __init__(self, name): Exception.__init__(self, self.msg % name) - + + class WebFault(Exception): def __init__(self, fault, document): if hasattr(fault, 'faultstring'): @@ -82,16 +89,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): @@ -138,17 +148,15 @@ 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)) -import client +def objid(obj): + return obj.__class__.__name__ + ':' + hex(id(obj)) diff --git a/suds/bindings/__init__.py b/txsuds/bindings/__init__.py similarity index 99% rename from suds/bindings/__init__.py rename to txsuds/bindings/__init__.py index 5471eba..d71123e 100644 --- a/suds/bindings/__init__.py +++ b/txsuds/bindings/__init__.py @@ -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, @@ -17,4 +17,4 @@ """ Provides modules containing classes to support Web Services (SOAP) bindings. -""" \ No newline at end of file +""" diff --git a/suds/bindings/binding.py b/txsuds/bindings/binding.py similarity index 96% rename from suds/bindings/binding.py rename to txsuds/bindings/binding.py index fff56e2..bb5ce4e 100644 --- a/suds/bindings/binding.py +++ b/txsuds/bindings/binding.py @@ -19,21 +19,20 @@ """ from logging import getLogger -from suds import * -from suds.sax import Namespace -from suds.sax.parser import Parser -from suds.sax.document import Document -from suds.sax.element import Element -from suds.sudsobject import Factory, Object -from suds.mx import Content -from suds.mx.literal import Literal as MxLiteral -from suds.umx.basic import Basic as UmxBasic -from suds.umx.typed import Typed as UmxTyped -from suds.bindings.multiref import MultiRef -from suds.xsd.query import TypeQuery, ElementQuery -from suds.xsd.sxbasic import Element as SchemaElement -from suds.options import Options -from suds.plugin import PluginContainer +from txsuds import * +from txsuds.sax import Namespace +from txsuds.sax.parser import Parser +from txsuds.sax.document import Document +from txsuds.sax.element import Element +from txsuds.sudsobject import Factory +from txsuds.mx import Content +from txsuds.mx.literal import Literal as MxLiteral +from txsuds.umx.basic import Basic as UmxBasic +from txsuds.umx.typed import Typed as UmxTyped +from txsuds.bindings.multiref import MultiRef +from txsuds.xsd.query import TypeQuery, ElementQuery +from txsuds.xsd.sxbasic import Element as SchemaElement +from txsuds.plugin import PluginContainer from copy import deepcopy log = getLogger(__name__) diff --git a/suds/bindings/document.py b/txsuds/bindings/document.py similarity index 97% rename from suds/bindings/document.py rename to txsuds/bindings/document.py index 9772abc..cf4954b 100644 --- a/suds/bindings/document.py +++ b/txsuds/bindings/document.py @@ -19,10 +19,10 @@ """ from logging import getLogger -from suds import * -from suds.bindings.binding import Binding -from suds.sax.element import Attribute -from suds.sax.element import Element +from txsuds import * +from txsuds.bindings.binding import Binding +from txsuds.sax.element import Attribute +from txsuds.sax.element import Element log = getLogger(__name__) diff --git a/suds/bindings/multiref.py b/txsuds/bindings/multiref.py similarity index 93% rename from suds/bindings/multiref.py rename to txsuds/bindings/multiref.py index e539592..97fabbf 100644 --- a/suds/bindings/multiref.py +++ b/txsuds/bindings/multiref.py @@ -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, @@ -19,26 +19,26 @@ """ from logging import getLogger -from suds import * -from suds.sax.element import Element +from txsuds import * log = getLogger(__name__) soapenc = (None, 'http://schemas.xmlsoap.org/soap/encoding/') + class MultiRef: """ Resolves and replaces multirefs. @ivar nodes: A list of non-multiref nodes. @type nodes: list @ivar catalog: A dictionary of multiref nodes by id. - @type catalog: dict + @type catalog: dict """ - + def __init__(self): self.nodes = [] self.catalog = {} - + def process(self, body): """ Process the specified soap envelope body and replace I{multiref} node @@ -54,7 +54,7 @@ def process(self, body): self.update(body) body.children = self.nodes return body - + def update(self, node): """ Update the specified I{node} by replacing the I{multiref} references with @@ -68,12 +68,12 @@ def update(self, node): for c in node.children: self.update(c) return node - + def replace_references(self, node): """ - Replacing the I{multiref} references with the contents of the + Replacing the I{multiref} references with the contents of the referenced nodes and remove the I{href} attribute. Warning: since - the I{ref} is not cloned, + the I{ref} is not cloned, @param node: A node to update. @type node: L{Element} """ @@ -91,7 +91,7 @@ def replace_references(self, node): if a.name != 'id': node.append(a) node.remove(href) - + def build_catalog(self, body): """ Create the I{catalog} of multiref nodes by id and the list of @@ -103,7 +103,8 @@ def build_catalog(self, body): if self.soaproot(child): self.nodes.append(child) id = child.get('id') - if id is None: continue + if id is None: + continue key = '#%s' % id self.catalog[key] = child @@ -122,5 +123,4 @@ def soaproot(self, node): if root is None: return True else: - return ( root.value == '1' ) - \ No newline at end of file + return (root.value == '1') diff --git a/suds/bindings/rpc.py b/txsuds/bindings/rpc.py similarity index 93% rename from suds/bindings/rpc.py rename to txsuds/bindings/rpc.py index 1bcc935..cfc6000 100644 --- a/suds/bindings/rpc.py +++ b/txsuds/bindings/rpc.py @@ -19,17 +19,18 @@ """ from logging import getLogger -from suds import * -from suds.mx.encoded import Encoded as MxEncoded -from suds.umx.encoded import Encoded as UmxEncoded -from suds.bindings.binding import Binding -from suds.sax.element import Element +from txsuds import * +from txsuds.mx.encoded import Encoded as MxEncoded +from txsuds.umx.encoded import Encoded as UmxEncoded +from txsuds.bindings.binding import Binding +from txsuds.sax.element import Element log = getLogger(__name__) encns = ('SOAP-ENC', 'http://schemas.xmlsoap.org/soap/encoding/') + class RPC(Binding): """ RPC/Literal binding style. diff --git a/suds/builder.py b/txsuds/builder.py similarity index 97% rename from suds/builder.py rename to txsuds/builder.py index c2aad98..61fa12b 100644 --- a/suds/builder.py +++ b/txsuds/builder.py @@ -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, @@ -19,22 +19,22 @@ """ from logging import getLogger -from suds import * -from suds.sudsobject import Factory +from txsuds import * +from txsuds.sudsobject import Factory log = getLogger(__name__) class Builder: """ Builder used to construct an object for types defined in the schema """ - + def __init__(self, resolver): """ @param resolver: A schema object name resolver. @type resolver: L{resolver.Resolver} """ self.resolver = resolver - + def build(self, name): """ build a an object for the specified typename as defined in the schema """ if isinstance(name, basestring): @@ -59,7 +59,7 @@ def build(self, name): continue self.process(data, child, history[:]) return data - + def process(self, data, type, history): """ process the specified type then process its children """ if type in history: @@ -98,7 +98,7 @@ def add_attributes(self, data, type): name = '_%s' % attr.name value = attr.get_default() setattr(data, name, value) - + def skip_child(self, child, ancestry): """ get whether or not to skip the specified child """ if child.any(): return True @@ -106,7 +106,7 @@ def skip_child(self, child, ancestry): if x.choice(): return True return False - + def ordering(self, type): """ get the ordering """ result = [] @@ -118,4 +118,3 @@ def ordering(self, type): name = '_%s' % child.name result.append(name) return result - \ No newline at end of file diff --git a/suds/cache.py b/txsuds/cache.py similarity index 94% rename from suds/cache.py rename to txsuds/cache.py index 8043c80..f2a188c 100644 --- a/suds/cache.py +++ b/txsuds/cache.py @@ -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, @@ -19,14 +19,13 @@ """ import os -import suds +import txsuds as suds from tempfile import gettempdir as tmp -from suds.transport import * -from suds.sax.parser import Parser -from suds.sax.element import Element +from txsuds.transport import * +from txsuds.sax.parser import Parser +from txsuds.sax.element import Element from datetime import datetime as dt from datetime import timedelta -from cStringIO import StringIO from logging import getLogger try: import cPickle as pickle @@ -50,7 +49,7 @@ def get(self, id): @rtype: any """ raise Exception('not-implemented') - + def getf(self, id): """ Get a object from the cache by ID. @@ -60,7 +59,7 @@ def getf(self, id): @rtype: any """ raise Exception('not-implemented') - + def put(self, id, object): """ Put a object into the cache. @@ -70,7 +69,7 @@ def put(self, id, object): @type object: any """ raise Exception('not-implemented') - + def putf(self, id, fp): """ Write a fp into the cache. @@ -80,33 +79,33 @@ def putf(self, id, fp): @type fp: file-like object. """ raise Exception('not-implemented') - + def purge(self, id): """ Purge a object from the cache by id. @param id: A object ID. - @type id: str + @type id: str """ raise Exception('not-implemented') - + def clear(self): """ Clear all objects from the cache. """ raise Exception('not-implemented') - + class NoCache(Cache): """ The passthru object cache. """ - + def get(self, id): return None - + def getf(self, id): return None - + def put(self, id, object): pass @@ -127,7 +126,7 @@ class FileCache(Cache): """ fnprefix = 'suds' units = ('months', 'weeks', 'days', 'hours', 'minutes', 'seconds') - + def __init__(self, location=None, **duration): """ @param location: The directory for the cached files. @@ -143,7 +142,7 @@ def __init__(self, location=None, **duration): self.duration = (None, 0) self.setduration(**duration) self.checkversion() - + def fnsuffix(self): """ Get the file name suffix @@ -151,10 +150,10 @@ def fnsuffix(self): @rtype: str """ return 'gcf' - + def setduration(self, **duration): """ - Set the caching duration which defines how long the + Set the caching duration which defines how long the file will be cached. @param duration: The cached file duration which defines how long the file will be cached. A duration=0 means forever. @@ -167,7 +166,7 @@ def setduration(self, **duration): raise Exception('must be: %s' % str(self.units)) self.duration = arg return self - + def setlocation(self, location): """ Set the location (directory) for the cached files. @@ -175,7 +174,7 @@ def setlocation(self, location): @type location: str """ self.location = location - + def mktmp(self): """ Make the I{location} directory if it doesn't already exits. @@ -186,7 +185,7 @@ def mktmp(self): except: log.debug(self.location, exc_info=1) return self - + def put(self, id, bfr): try: fn = self.__fn(id) @@ -197,7 +196,7 @@ def put(self, id, bfr): except: log.debug(id, exc_info=1) return bfr - + def putf(self, id, fp): try: fn = self.__fn(id) @@ -209,7 +208,7 @@ def putf(self, id, fp): except: log.debug(id, exc_info=1) return fp - + def get(self, id): try: f = self.getf(id) @@ -218,7 +217,7 @@ def get(self, id): return bfr except: pass - + def getf(self, id): try: fn = self.__fn(id) @@ -241,7 +240,7 @@ def validate(self, fn): if expired < dt.now(): log.debug('%s expired, deleted', fn) os.remove(fn) - + def clear(self): for fn in os.listdir(self.location): path = os.path.join(self.location, fn) @@ -250,25 +249,25 @@ def clear(self): if fn.startswith(self.fnprefix): os.remove(path) log.debug('deleted: %s', path) - + def purge(self, id): fn = self.__fn(id) try: os.remove(fn) except: pass - + def open(self, fn, *args): """ Open the cache file making sure the directory is created. """ self.mktmp() return open(fn, *args) - + def checkversion(self): path = os.path.join(self.location, 'version') try: - + f = self.open(path) version = f.read() f.close() @@ -278,23 +277,23 @@ def checkversion(self): self.clear() f = self.open(path, 'w') f.write(suds.__version__) - f.close() - + f.close() + def __fn(self, id): name = id suffix = self.fnsuffix() fn = '%s-%s.%s' % (self.fnprefix, name, suffix) return os.path.join(self.location, fn) - - + + class DocumentCache(FileCache): """ Provides xml document caching. """ - + def fnsuffix(self): return 'xml' - + def get(self, id): try: fp = FileCache.getf(self, id) @@ -304,7 +303,7 @@ def get(self, id): return p.parse(fp) except: FileCache.purge(self, id) - + def put(self, id, object): if isinstance(object, Element): FileCache.put(self, id, str(object)) @@ -318,10 +317,10 @@ class ObjectCache(FileCache): @type protocol: int """ protocol = 2 - + def fnsuffix(self): return 'px' - + def get(self, id): try: fp = FileCache.getf(self, id) @@ -331,7 +330,7 @@ def get(self, id): return pickle.load(fp) except: FileCache.purge(self, id) - + def put(self, id, object): bfr = pickle.dumps(object, self.protocol) FileCache.put(self, id, bfr) diff --git a/suds/client.py b/txsuds/client.py similarity index 97% rename from suds/client.py rename to txsuds/client.py index 6c84b6b..ab9b771 100644 --- a/suds/client.py +++ b/txsuds/client.py @@ -19,29 +19,24 @@ See I{README.txt} """ -import suds -import suds.metrics as metrics +import txsuds.metrics as metrics from cookielib import CookieJar -from suds import * -from suds.reader import DefinitionsReader -from suds.transport import TransportError, Request -from suds.transport.https import HttpAuthenticated -from suds.transport.twisted_transport import TwistedTransport -from suds.servicedefinition import ServiceDefinition -from suds import sudsobject +from txsuds import * +from txsuds.reader import DefinitionsReader +from txsuds.transport import TransportError, Request +from txsuds.transport.twisted_transport import TwistedTransport +from txsuds.servicedefinition import ServiceDefinition +from txsuds import sudsobject from sudsobject import Factory as InstFactory -from sudsobject import Object -from suds.resolver import PathResolver -from suds.builder import Builder -from suds.wsdl import Definitions -from suds.cache import ObjectCache -from suds.sax.document import Document -from suds.sax.parser import Parser -from suds.options import Options -from suds.properties import Unskin -from urlparse import urlparse +from txsuds.resolver import PathResolver +from txsuds.builder import Builder +from txsuds.wsdl import Definitions +from txsuds.cache import ObjectCache +from txsuds.sax.parser import Parser +from txsuds.options import Options +from txsuds.properties import Unskin from copy import deepcopy -from suds.plugin import PluginContainer +from txsuds.plugin import PluginContainer from logging import getLogger log = getLogger(__name__) @@ -208,6 +203,7 @@ def __str__(self): def __unicode__(self): s = ['\n'] + import txsuds as suds build = suds.__build__.split() s.append('Suds ( https://fedorahosted.org/suds/ )') s.append(' version: %s' % suds.__version__) diff --git a/suds/metrics.py b/txsuds/metrics.py similarity index 94% rename from suds/metrics.py rename to txsuds/metrics.py index 403224a..ab9cab8 100644 --- a/suds/metrics.py +++ b/txsuds/metrics.py @@ -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, @@ -21,11 +21,12 @@ import time from logging import getLogger -from suds import * +from txsuds import * from math import modf log = getLogger(__name__) + class Timer: def __init__(self): @@ -43,7 +44,7 @@ def stop(self): return self def duration(self): - return ( self.stopped - self.started ) + return (self.stopped - self.started) def __str__(self): if self.started == 0: @@ -54,7 +55,7 @@ def __str__(self): jmod = ( lambda m : (m[1], m[0]*1000) ) if duration < 1: ms = (duration*1000) - return '%d (ms)' % ms + return '%d (ms)' % ms if duration < 60: m = modf(duration) return '%d.%.3d (seconds)' % jmod(m) diff --git a/suds/mx/__init__.py b/txsuds/mx/__init__.py similarity index 93% rename from suds/mx/__init__.py rename to txsuds/mx/__init__.py index 77e6ca1..f859cab 100644 --- a/suds/mx/__init__.py +++ b/txsuds/mx/__init__.py @@ -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, @@ -19,7 +19,7 @@ marshalling (XML). """ -from suds.sudsobject import Object +from txsuds.sudsobject import Object class Content(Object): @@ -30,9 +30,9 @@ class Content(Object): @ivar value: The content's value. @type value: I{any} """ - + extensions = [] - + def __init__(self, tag=None, value=None, **kwargs): """ @param tag: The content tag. @@ -43,9 +43,9 @@ def __init__(self, tag=None, value=None, **kwargs): Object.__init__(self) self.tag = tag self.value = value - for k,v in kwargs.items(): + for k, v in kwargs.items(): setattr(self, k, v) - + def __getattr__(self, name): if name not in self.__dict__: if name in self.extensions: @@ -56,4 +56,4 @@ def __getattr__(self, name): 'Content has no attribute %s' % name else: v = self.__dict__[name] - return v \ No newline at end of file + return v diff --git a/suds/mx/appender.py b/txsuds/mx/appender.py similarity index 93% rename from suds/mx/appender.py rename to txsuds/mx/appender.py index 206abc0..e308746 100644 --- a/suds/mx/appender.py +++ b/txsuds/mx/appender.py @@ -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, @@ -19,16 +19,16 @@ """ from logging import getLogger -from suds import * -from suds.mx import * -from suds.sudsobject import footprint -from suds.sudsobject import Object, Property -from suds.sax.element import Element -from suds.sax.text import Text -from copy import deepcopy +from txsuds import * +from txsuds.mx import * +from txsuds.sudsobject import footprint +from txsuds.sudsobject import Object, Property +from txsuds.sax.element import Element +from txsuds.sax.text import Text log = getLogger(__name__) + class Matcher: """ Appender matcher. @@ -45,7 +45,7 @@ def __init__(self, cls): def __eq__(self, x): if self.cls is None: - return ( x is None ) + return (x is None) else: return isinstance(x, self.cls) @@ -74,18 +74,18 @@ def __init__(self, marshaller): PropertyAppender(marshaller)), (Matcher(Object), ObjectAppender(marshaller)), - (Matcher(Element), + (Matcher(Element), ElementAppender(marshaller)), - (Matcher(Text), + (Matcher(Text), TextAppender(marshaller)), - (Matcher(list), + (Matcher(list), ListAppender(marshaller)), - (Matcher(tuple), + (Matcher(tuple), ListAppender(marshaller)), - (Matcher(dict), + (Matcher(dict), DictAppender(marshaller)), ) - + def append(self, parent, content): """ Select an appender and append the content to parent. @@ -108,14 +108,14 @@ class Appender: @ivar marshaller: A marshaller. @type marshaller: L{suds.mx.core.Core} """ - + def __init__(self, marshaller): """ @param marshaller: A marshaller. @type marshaller: L{suds.mx.core.Core} """ self.marshaller = marshaller - + def node(self, content): """ Create and return an XML node that is qualified @@ -127,7 +127,7 @@ def node(self, content): @rtype: L{Element} """ return self.marshaller.node(content) - + def setnil(self, node, content): """ Set the value of the I{node} to nill. @@ -137,7 +137,7 @@ def setnil(self, node, content): @type content: L{Object} """ self.marshaller.setnil(node, content) - + def setdefault(self, node, content): """ Set the value of the I{node} to a default value. @@ -148,7 +148,7 @@ def setdefault(self, node, content): @return: The default. """ return self.marshaller.setdefault(node, content) - + def optional(self, content): """ Get whether the specified content is optional. @@ -156,7 +156,7 @@ def optional(self, content): @type content: L{Content} """ return self.marshaller.optional(content) - + def suspend(self, content): """ Notify I{marshaller} that appending this content has suspended. @@ -164,7 +164,7 @@ def suspend(self, content): @type content: L{Object} """ self.marshaller.suspend(content) - + def resume(self, content): """ Notify I{marshaller} that appending this content has resumed. @@ -172,7 +172,7 @@ def resume(self, content): @type content: L{Object} """ self.marshaller.resume(content) - + def append(self, parent, content): """ Append the specified L{content} to the I{parent}. @@ -181,12 +181,12 @@ def append(self, parent, content): """ self.marshaller.append(parent, content) - + class PrimativeAppender(Appender): """ An appender for python I{primative} types. """ - + def append(self, parent, content): if content.tag.startswith('_'): attr = content.tag[1:] @@ -203,7 +203,7 @@ class NoneAppender(Appender): """ An appender for I{None} values. """ - + def append(self, parent, content): child = self.node(content) default = self.setdefault(child, content) @@ -216,7 +216,7 @@ class PropertyAppender(Appender): """ A L{Property} appender. """ - + def append(self, parent, content): p = content.value child = self.node(content) @@ -226,12 +226,12 @@ def append(self, parent, content): cont = Content(tag=item[0], value=item[1]) Appender.append(self, child, cont) - + class ObjectAppender(Appender): """ An L{Object} appender. """ - + def append(self, parent, content): object = content.value if self.optional(content) and footprint(object) == 0: @@ -241,13 +241,13 @@ def append(self, parent, content): for item in object: cont = Content(tag=item[0], value=item[1]) Appender.append(self, child, cont) - + class DictAppender(Appender): """ An python I{dict} appender. """ - + def append(self, parent, content): d = content.value if self.optional(content) and len(d) == 0: @@ -257,17 +257,17 @@ def append(self, parent, content): for item in d.items(): cont = Content(tag=item[0], value=item[1]) Appender.append(self, child, cont) - + class ElementWrapper(Element): """ Element wrapper. """ - + def __init__(self, content): Element.__init__(self, content.name, content.parent) self.__content = content - + def str(self, indent=0): return self.__content.str(indent) diff --git a/suds/mx/basic.py b/txsuds/mx/basic.py similarity index 93% rename from suds/mx/basic.py rename to txsuds/mx/basic.py index 336f684..3c71493 100644 --- a/suds/mx/basic.py +++ b/txsuds/mx/basic.py @@ -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, @@ -19,9 +19,9 @@ """ from logging import getLogger -from suds import * -from suds.mx import * -from suds.mx.core import Core +from txsuds import * +from txsuds.mx import * +from txsuds.mx.core import Core log = getLogger(__name__) @@ -30,7 +30,7 @@ class Basic(Core): """ A I{basic} (untyped) marshaller. """ - + def process(self, value, tag=None): """ Process (marshal) the tag with the specified value using the @@ -45,4 +45,4 @@ def process(self, value, tag=None): """ content = Content(tag=tag, value=value) result = Core.process(self, content) - return result \ No newline at end of file + return result diff --git a/suds/mx/core.py b/txsuds/mx/core.py similarity index 95% rename from suds/mx/core.py rename to txsuds/mx/core.py index 3c9ef59..07d1058 100644 --- a/suds/mx/core.py +++ b/txsuds/mx/core.py @@ -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, @@ -19,12 +19,12 @@ """ from logging import getLogger -from suds import * -from suds.mx import * -from suds.mx.appender import ContentAppender -from suds.sax.element import Element -from suds.sax.document import Document -from suds.sudsobject import Property +from txsuds import * +from txsuds.mx import * +from txsuds.mx.appender import ContentAppender +from txsuds.sax.element import Element +from txsuds.sax.document import Document +from txsuds.sudsobject import Property log = getLogger(__name__) @@ -61,7 +61,7 @@ def process(self, content): else: self.append(document, content) return document.root() - + def append(self, parent, content): """ Append the specified L{content} to the I{parent}. @@ -90,7 +90,7 @@ def node(self, content): @rtype: L{Element} """ return Element(content.tag) - + def start(self, content): """ Appending this content has started. @@ -100,7 +100,7 @@ def start(self, content): @rtype: boolean """ return True - + def suspend(self, content): """ Appending this content has suspended. @@ -108,7 +108,7 @@ def suspend(self, content): @type content: L{Content} """ pass - + def resume(self, content): """ Appending this content has resumed. @@ -126,7 +126,7 @@ def end(self, parent, content): @type content: L{Content} """ pass - + def setnil(self, node, content): """ Set the value of the I{node} to nill. @@ -147,7 +147,7 @@ def setdefault(self, node, content): @return: The default. """ pass - + def optional(self, content): """ Get whether the specified content is optional. @@ -155,4 +155,3 @@ def optional(self, content): @type content: L{Content} """ return False - diff --git a/suds/mx/encoded.py b/txsuds/mx/encoded.py similarity index 90% rename from suds/mx/encoded.py rename to txsuds/mx/encoded.py index 9cbc8c5..358af3e 100644 --- a/suds/mx/encoded.py +++ b/txsuds/mx/encoded.py @@ -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, @@ -19,12 +19,12 @@ """ from logging import getLogger -from suds import * -from suds.mx import * -from suds.mx.literal import Literal -from suds.mx.typer import Typer -from suds.sudsobject import Factory, Object -from suds.xsd.query import TypeQuery +from txsuds import * +from txsuds.mx import * +from txsuds.mx.literal import Literal +from txsuds.mx.typer import Typer +from txsuds.sudsobject import Factory, Object +from txsuds.xsd.query import TypeQuery log = getLogger(__name__) @@ -40,13 +40,13 @@ class Encoded(Literal): A SOAP section (5) encoding marshaller. This marshaller supports rpc/encoded soap styles. """ - + def start(self, content): # # For soap encoded arrays, the 'aty' (array type) information # is extracted and added to the 'content'. Then, the content.value # is replaced with an object containing an 'item=[]' attribute - # containing values that are 'typed' suds objects. + # containing values that are 'typed' suds objects. # start = Literal.start(self, content) if start and isinstance(content.value, (list,tuple)): @@ -57,7 +57,7 @@ def start(self, content): self.cast(content) break return start - + def end(self, parent, content): # # For soap encoded arrays, the soapenc:arrayType attribute is @@ -75,9 +75,9 @@ def end(self, parent, content): child.addPrefix(ns0[0], ns0[1]) child.addPrefix(ns1[0], ns1[1]) name = '%s:arrayType' % ns1[0] - value = '%s:%s[%d]' % (ns0[0], aty[0], len(array)) + value = '%s:%s[%d]' % (ns0[0], aty[0], len(array)) child.set(name, value) - + def encode(self, node, content): if content.type.any(): Typer.auto(node, content.value) @@ -90,7 +90,7 @@ def encode(self, node, content): if self.xstq: ns = content.real.namespace() Typer.manual(node, name, ns) - + def cast(self, content): """ Cast the I{untyped} list items found in content I{value}. @@ -117,13 +117,13 @@ def cast(self, content): if isinstance(x, Object): md = x.__metadata__ md.sxtype = ref - array.item.append(x) + array.item.append(x) continue if isinstance(x, dict): x = Factory.object(ref.name, x) md = x.__metadata__ md.sxtype = ref - array.item.append(x) + array.item.append(x) continue x = Factory.property(ref.name, x) md = x.__metadata__ diff --git a/suds/mx/literal.py b/txsuds/mx/literal.py similarity index 96% rename from suds/mx/literal.py rename to txsuds/mx/literal.py index 937ad8e..9c150d1 100644 --- a/suds/mx/literal.py +++ b/txsuds/mx/literal.py @@ -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, @@ -19,13 +19,13 @@ """ from logging import getLogger -from suds import * -from suds.mx import * -from suds.mx.core import Core -from suds.mx.typer import Typer -from suds.resolver import GraphResolver, Frame -from suds.sax.element import Element -from suds.sudsobject import Factory +from txsuds import * +from txsuds.mx import * +from txsuds.mx.core import Core +from txsuds.mx.typer import Typer +from txsuds.resolver import GraphResolver, Frame +from txsuds.sax.element import Element +from txsuds.sudsobject import Factory log = getLogger(__name__) @@ -41,7 +41,6 @@ Content.extensions.append('ancestry') - class Typed(Core): """ A I{typed} marshaller. @@ -65,10 +64,10 @@ def __init__(self, schema, xstq=True): self.schema = schema self.xstq = xstq self.resolver = GraphResolver(self.schema) - + def reset(self): self.resolver.reset() - + def start(self, content): # # Start marshalling the 'content' by ensuring that both the @@ -105,7 +104,7 @@ def start(self, content): return False else: return True - + def suspend(self, content): # # Suspend to process a list content. Primarily, this @@ -113,7 +112,7 @@ def suspend(self, content): # stack so the list items can be marshalled. # self.resolver.pop() - + def resume(self, content): # # Resume processing a list content. To do this, we @@ -121,7 +120,7 @@ def resume(self, content): # back onto the resolver stack. # self.resolver.push(Frame(content.type)) - + def end(self, parent, content): # # End processing the content. Make sure the content @@ -136,7 +135,7 @@ def end(self, parent, content): raise Exception, \ 'content (end) mismatch: top=(%s) cont=(%s)' % \ (current, content) - + def node(self, content): # # Create an XML node and namespace qualify as defined @@ -151,7 +150,7 @@ def node(self, content): self.encode(node, content) log.debug('created - node:\n%s', node) return node - + def setnil(self, node, content): # # Set the 'node' nil only if the XSD type @@ -159,7 +158,7 @@ def setnil(self, node, content): # if content.type.nillable: node.setnil() - + def setdefault(self, node, content): # # Set the node to the default value specified @@ -171,7 +170,7 @@ def setdefault(self, node, content): else: node.setText(default) return default - + def optional(self, content): if content.type.optional(): return True @@ -179,7 +178,7 @@ def optional(self, content): if a.optional(): return True return False - + def encode(self, node, content): # Add (soap) encoding information only if the resolved # type is derived by extension. Further, the xsi:type values @@ -196,7 +195,7 @@ def encode(self, node, content): if self.xstq: ns = content.real.namespace('ns1') Typer.manual(node, name, ns) - + def skip(self, content): """ Get whether to skip this I{content}. @@ -214,7 +213,7 @@ def skip(self, content): if isinstance(v, (list,tuple)) and len(v) == 0: return True return False - + def optional(self, content): if content.type.optional(): return True @@ -222,7 +221,7 @@ def optional(self, content): if a.optional(): return True return False - + def translate(self, content): """ Translate using the XSD type information. @@ -246,7 +245,7 @@ def translate(self, content): v = content.real.translate(v, False) content.value = v return self - + def sort(self, content): """ Sort suds object attributes based on ordering defined diff --git a/suds/mx/typer.py b/txsuds/mx/typer.py similarity index 95% rename from suds/mx/typer.py rename to txsuds/mx/typer.py index ea88df7..53860d8 100644 --- a/suds/mx/typer.py +++ b/txsuds/mx/typer.py @@ -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, @@ -19,10 +19,10 @@ """ from logging import getLogger -from suds import * -from suds.mx import * -from suds.sax import Namespace as NS -from suds.sax.text import Text +from txsuds import * +from txsuds.mx import * +from txsuds.sax import Namespace as NS +from txsuds.sax.text import Text log = getLogger(__name__) @@ -43,7 +43,7 @@ class Typer: Text : ('string', NS.xsdns), bool : ('boolean', NS.xsdns), } - + @classmethod def auto(cls, node, value=None): """ @@ -92,9 +92,9 @@ class or the class of the node's text. Then adds the referenced ns = cls.genprefix(node, ns) qname = ':'.join((ns[0], tval)) node.set(xta, qname) - node.addPrefix(ns[0], ns[1]) + node.addPrefix(ns[0], ns[1]) return node - + @classmethod def genprefix(cls, node, ns): """ @@ -111,7 +111,7 @@ def genprefix(cls, node, ns): if u is None or u == ns[1]: return (p, ns[1]) raise Exception('auto prefix, exhausted') - + @classmethod def known(cls, object): try: diff --git a/suds/options.py b/txsuds/options.py similarity index 96% rename from suds/options.py rename to txsuds/options.py index 63551c2..bef3d40 100644 --- a/suds/options.py +++ b/txsuds/options.py @@ -18,11 +18,11 @@ Suds basic options classes. """ -from suds.properties import * -from suds.wsse import Security -from suds.xsd.doctor import Doctor -from suds.transport import Transport -from suds.cache import Cache, NoCache +from txsuds.properties import * +from txsuds.wsse import Security +from txsuds.xsd.doctor import Doctor +from txsuds.transport import Transport +from txsuds.cache import Cache, NoCache class TpLinker(AutoLinker): diff --git a/suds/plugin.py b/txsuds/plugin.py similarity index 95% rename from suds/plugin.py rename to txsuds/plugin.py index 061c564..6cf688d 100644 --- a/suds/plugin.py +++ b/txsuds/plugin.py @@ -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, @@ -19,7 +19,7 @@ of suds plugins. """ -from suds import * +from txsuds import * from logging import getLogger log = getLogger(__name__) @@ -51,7 +51,7 @@ class DocumentContext(Context): """ pass - + class MessageContext(Context): """ The context for sending the soap envelope. @@ -74,7 +74,7 @@ class InitPlugin(Plugin): """ The base class for suds I{init} plugins. """ - + def initialized(self, context): """ Suds client initialization. @@ -90,17 +90,17 @@ class DocumentPlugin(Plugin): """ The base class for suds I{document} plugins. """ - - def loaded(self, context): + + def loaded(self, context): """ - Suds has loaded a WSDL/XSD document. Provides the plugin - with an opportunity to inspect/modify the unparsed document. - Called after each WSDL/XSD document is loaded. - @param context: The document context. - @type context: L{DocumentContext} + Suds has loaded a WSDL/XSD document. Provides the plugin + with an opportunity to inspect/modify the unparsed document. + Called after each WSDL/XSD document is loaded. + @param context: The document context. + @type context: L{DocumentContext} """ - pass - + pass + def parsed(self, context): """ Suds has parsed a WSDL/XSD document. Provides the plugin @@ -116,7 +116,7 @@ class MessagePlugin(Plugin): """ The base class for suds I{soap message} plugins. """ - + def marshalled(self, context): """ Suds will send the specified soap envelope. @@ -127,7 +127,7 @@ def marshalled(self, context): @type context: L{MessageContext} """ pass - + def sending(self, context): """ Suds will send the specified soap envelope. @@ -138,7 +138,7 @@ def sending(self, context): @type context: L{MessageContext} """ pass - + def received(self, context): """ Suds has received the specified reply. @@ -149,7 +149,7 @@ def received(self, context): @type context: L{MessageContext} """ pass - + def parsed(self, context): """ Suds has sax parsed the received reply. @@ -160,7 +160,7 @@ def parsed(self, context): @type context: L{MessageContext} """ pass - + def unmarshalled(self, context): """ Suds has unmarshalled the received reply. @@ -172,7 +172,7 @@ def unmarshalled(self, context): """ pass - + class PluginContainer: """ Plugin container provides easy method invocation. @@ -181,20 +181,20 @@ class PluginContainer: @cvar ctxclass: A dict of plugin method / context classes. @type ctxclass: dict """ - + domains = {\ 'init': (InitContext, InitPlugin), 'document': (DocumentContext, DocumentPlugin), 'message': (MessageContext, MessagePlugin ), } - + def __init__(self, plugins): """ @param plugins: A list of plugin objects. @type plugins: [L{Plugin},] """ self.plugins = plugins - + def __getattr__(self, name): domain = self.domains.get(name) if domain: @@ -206,8 +206,8 @@ def __getattr__(self, name): return PluginDomain(ctx, plugins) else: raise Exception, 'plugin domain (%s), invalid' % name - - + + class PluginDomain: """ The plugin domain. @@ -216,11 +216,11 @@ class PluginDomain: @ivar plugins: A list of plugins (targets). @type plugins: list """ - + def __init__(self, ctx, plugins): self.ctx = ctx self.plugins = plugins - + def __getattr__(self, name): return Method(name, self) @@ -243,7 +243,7 @@ def __init__(self, name, domain): """ self.name = name self.domain = domain - + def __call__(self, **kwargs): ctx = self.domain.ctx() ctx.__dict__.update(kwargs) diff --git a/suds/properties.py b/txsuds/properties.py similarity index 100% rename from suds/properties.py rename to txsuds/properties.py diff --git a/suds/reader.py b/txsuds/reader.py similarity index 96% rename from suds/reader.py rename to txsuds/reader.py index f87819f..e42ff35 100644 --- a/suds/reader.py +++ b/txsuds/reader.py @@ -19,11 +19,11 @@ """ -from suds.sax.parser import Parser -from suds.transport import Request -from suds.cache import Cache, NoCache -from suds.store import DocumentStore -from suds.plugin import PluginContainer +from txsuds.sax.parser import Parser +from txsuds.transport import Request +from txsuds.cache import NoCache +from txsuds.store import DocumentStore +from txsuds.plugin import PluginContainer from logging import getLogger from twisted.internet import defer diff --git a/suds/resolver.py b/txsuds/resolver.py similarity index 97% rename from suds/resolver.py rename to txsuds/resolver.py index 278b5da..09d2701 100644 --- a/suds/resolver.py +++ b/txsuds/resolver.py @@ -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, @@ -21,10 +21,10 @@ import re from logging import getLogger -from suds import * -from suds.sax import splitPrefix, Namespace -from suds.sudsobject import Object -from suds.xsd.query import BlindQuery, TypeQuery, qualify +from txsuds import * +from txsuds.sax import splitPrefix, Namespace +from txsuds.sudsobject import Object +from txsuds.xsd.query import BlindQuery, qualify log = getLogger(__name__) @@ -42,7 +42,7 @@ def __init__(self, schema): @type schema: L{xsd.schema.Schema} """ self.schema = schema - + def find(self, name, resolved=True): """ Get the definition object for the schema object by name. @@ -114,7 +114,7 @@ def find(self, path, resolved=True): except PathResolver.BadPath: log.error('path: "%s", not-found' % path) return result - + def root(self, parts): """ Find the path root. @@ -135,7 +135,7 @@ def root(self, parts): else: log.debug('found (%s) as (%s)', name, Repr(result)) return result - + def branch(self, root, parts): """ Traverse the path until the leaf is reached. @@ -158,7 +158,7 @@ def branch(self, root, parts): result = result.resolve(nobuiltin=True) log.debug('found (%s) as (%s)', name, Repr(result)) return result - + def leaf(self, parent, parts): """ Find the leaf. @@ -177,7 +177,7 @@ def leaf(self, parent, parts): if result is None: raise PathResolver.BadPath(name) return result - + def qualify(self, name): """ Qualify the name as either: @@ -194,7 +194,7 @@ def qualify(self, name): return qualify(name, self.wsdl.root, self.wsdl.tns) else: return (m.group(4), m.group(2)) - + def split(self, s): """ Split the string on (.) while preserving any (.) inside the @@ -214,7 +214,7 @@ def split(self, s): parts.append(s[b:e]) b = e+1 return parts - + class BadPath(Exception): pass @@ -227,7 +227,7 @@ class TreeResolver(Resolver): @ivar stack: The context stack. @type stack: list """ - + def __init__(self, schema): """ @param schema: A schema object. @@ -235,13 +235,13 @@ def __init__(self, schema): """ Resolver.__init__(self, schema) self.stack = Stack() - + def reset(self): """ Reset the resolver's state. """ self.stack = Stack() - + def push(self, x): """ Push an I{object} onto the stack. @@ -257,7 +257,7 @@ def push(self, x): self.stack.append(frame) log.debug('push: (%s)\n%s', Repr(frame), Repr(self.stack)) return frame - + def top(self): """ Get the I{frame} at the top of the stack. @@ -268,21 +268,21 @@ def top(self): return self.stack[-1] else: return Frame.Empty() - + def pop(self): """ Pop the frame at the top of the stack. @return: The popped frame, else None. @rtype: L{Frame} """ - if len(self.stack): + if len(self.stack): popped = self.stack.pop() log.debug('pop: (%s)\n%s', Repr(popped), Repr(self.stack)) return popped else: log.debug('stack empty, not-popped') return None - + def depth(self): """ Get the current stack depth. @@ -290,7 +290,7 @@ def depth(self): @rtype: int """ return len(self.stack) - + def getchild(self, name, parent): """ get a child by name """ log.debug('searching parent (%s) for (%s)', Repr(parent), name) @@ -307,14 +307,14 @@ class NodeResolver(TreeResolver): the tree structure to ensure that nodes are resolved in context. """ - + def __init__(self, schema): """ @param schema: A schema object. @type schema: L{xsd.schema.Schema} """ TreeResolver.__init__(self, schema) - + def find(self, node, resolved=False, push=True): """ @param node: An xml node to be resolved. @@ -343,7 +343,7 @@ def find(self, node, resolved=False, push=True): if resolved: result = result.resolve() return result - + def findattr(self, name, resolved=True): """ Find an attribute type definition. @@ -366,7 +366,7 @@ def findattr(self, name, resolved=True): if resolved: result = result.resolve() return result - + def query(self, name, node): """ blindly query the schema by name """ log.debug('searching schema for (%s)', name) @@ -374,7 +374,7 @@ def query(self, name, node): query = BlindQuery(qref) result = query.execute(self.schema) return (result, []) - + def known(self, node): """ resolve type referenced by @xsi:type """ ref = node.get('type', Namespace.xsins) @@ -383,7 +383,7 @@ def known(self, node): qref = qualify(ref, node, node.namespace()) query = BlindQuery(qref) return query.execute(self.schema) - + class GraphResolver(TreeResolver): """ @@ -392,20 +392,20 @@ class GraphResolver(TreeResolver): the tree structure to ensure that nodes are resolved in context. """ - + def __init__(self, schema): """ @param schema: A schema object. @type schema: L{xsd.schema.Schema} """ TreeResolver.__init__(self, schema) - + def find(self, name, object, resolved=False, push=True): """ @param name: The name of the object to be resolved. @type name: basestring @param object: The name's value. - @type object: (any|L{Object}) + @type object: (any|L{Object}) @param resolved: A flag indicating that the fully resolved type should be returned. @type resolved: boolean @@ -434,7 +434,7 @@ def find(self, name, object, resolved=False, push=True): else: result = known return result - + def query(self, name): """ blindly query the schema by name """ log.debug('searching schema for (%s)', name) @@ -447,7 +447,7 @@ def query(self, name): query = BlindQuery(qref) result = query.execute(schema) return (result, []) - + def wsdl(self): """ get the wsdl """ container = self.schema.container @@ -455,7 +455,7 @@ def wsdl(self): return None else: return container.wsdl - + def known(self, object): """ get the type specified in the object's metadata """ try: @@ -465,7 +465,7 @@ def known(self, object): except: pass - + class Frame: def __init__(self, type, resolved=None, ancestry=()): self.type = type @@ -479,7 +479,7 @@ def __str__(self): (Repr(self.type), Repr(self.resolved), [Repr(t) for t in self.ancestry]) - + class Empty: def __getattr__(self, name): if name == 'ancestry': diff --git a/suds/sax/__init__.py b/txsuds/sax/__init__.py similarity index 96% rename from suds/sax/__init__.py rename to txsuds/sax/__init__.py index 3d71432..aeceb45 100644 --- a/suds/sax/__init__.py +++ b/txsuds/sax/__init__.py @@ -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, @@ -29,7 +29,7 @@ @type encoder: L{Encoder} """ -from suds.sax.enc import Encoder +from txsuds.sax.enc import Encoder # # pluggable XML special character encoder. @@ -44,7 +44,7 @@ def splitPrefix(name): @param name: A node name containing an optional prefix. @type name: basestring @return: A tuple containing the (2) parts of I{name} - @rtype: (I{prefix}, I{name}) + @rtype: (I{prefix}, I{name}) """ if isinstance(name, basestring) \ and ':' in name: @@ -52,7 +52,7 @@ def splitPrefix(name): else: return (None, name) - + class Namespace: """ The namespace class represents XML namespaces. @@ -63,15 +63,15 @@ class Namespace: xsdns = ('xs', 'http://www.w3.org/2001/XMLSchema') xsins = ('xsi', 'http://www.w3.org/2001/XMLSchema-instance') all = (xsdns, xsins) - + @classmethod def create(cls, p=None, u=None): return (p, u) - + @classmethod def none(cls, ns): return ( ns == cls.default ) - + @classmethod def xsd(cls, ns): try: @@ -79,7 +79,7 @@ def xsd(cls, ns): except: pass return False - + @classmethod def xsi(cls, ns): try: @@ -87,7 +87,7 @@ def xsi(cls, ns): except: pass return False - + @classmethod def xs(cls, ns): return ( cls.xsd(ns) or cls.xsi(ns) ) @@ -99,7 +99,7 @@ def w3(cls, ns): except: pass return False - + @classmethod def isns(cls, ns): try: diff --git a/suds/sax/attribute.py b/txsuds/sax/attribute.py similarity index 96% rename from suds/sax/attribute.py rename to txsuds/sax/attribute.py index 86dfb11..666bb36 100644 --- a/suds/sax/attribute.py +++ b/txsuds/sax/attribute.py @@ -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, @@ -18,14 +18,15 @@ Provides XML I{attribute} classes. """ -import suds.sax +import txsuds.sax from logging import getLogger -from suds import * -from suds.sax import * -from suds.sax.text import Text +from txsuds import * +from txsuds.sax import * +from txsuds.sax.text import Text log = getLogger(__name__) + class Attribute: """ An XML attribute object. @@ -43,12 +44,12 @@ def __init__(self, name, value=None): @param name: The attribute's name with I{optional} namespace prefix. @type name: basestring @param value: The attribute's value - @type value: basestring + @type value: basestring """ self.parent = None self.prefix, self.name = splitPrefix(name) self.setValue(value) - + def clone(self, parent=None): """ Clone this object. @@ -60,7 +61,7 @@ def clone(self, parent=None): a = Attribute(self.qname(), self.value) a.parent = parent return a - + def qname(self): """ Get the B{fully} qualified name of this attribute @@ -71,7 +72,7 @@ def qname(self): return self.name else: return ':'.join((self.prefix, self.name)) - + def setValue(self, value): """ Set the attributes value @@ -85,7 +86,7 @@ def setValue(self, value): else: self.value = Text(value) return self - + def getValue(self, default=Text('')): """ Get the attributes value with optional default. @@ -99,7 +100,7 @@ def getValue(self, default=Text('')): return self.value else: return default - + def hasText(self): """ Get whether the attribute has I{text} and that it is not an empty @@ -108,7 +109,7 @@ def hasText(self): @rtype: boolean """ return ( self.value is not None and len(self.value) ) - + def namespace(self): """ Get the attributes namespace. This may either be the namespace @@ -120,7 +121,7 @@ def namespace(self): return Namespace.default else: return self.resolvePrefix(self.prefix) - + def resolvePrefix(self, prefix): """ Resolve the specified prefix to a known namespace. @@ -133,7 +134,7 @@ def resolvePrefix(self, prefix): if self.parent is not None: ns = self.parent.resolvePrefix(prefix) return ns - + def match(self, name=None, ns=None): """ Match by (optional) name and/or (optional) namespace. @@ -153,14 +154,14 @@ def match(self, name=None, ns=None): else: byns = ( self.namespace()[1] == ns[1] ) return ( byname and byns ) - + def __eq__(self, rhs): """ equals operator """ return rhs is not None and \ isinstance(rhs, Attribute) and \ self.prefix == rhs.name and \ self.name == rhs.name - + def __repr__(self): """ get a string representation """ return \ @@ -170,7 +171,7 @@ def __repr__(self): def __str__(self): """ get an xml string representation """ return unicode(self).encode('utf-8') - + def __unicode__(self): """ get an xml string representation """ n = self.qname() diff --git a/suds/sax/date.py b/txsuds/sax/date.py similarity index 99% rename from suds/sax/date.py rename to txsuds/sax/date.py index 3ac14cd..1bec49b 100644 --- a/suds/sax/date.py +++ b/txsuds/sax/date.py @@ -20,8 +20,8 @@ """ from logging import getLogger -from suds import * -from suds.xsd import * +from txsuds import * +from txsuds.xsd import * import time import datetime as dt import re diff --git a/suds/sax/document.py b/txsuds/sax/document.py similarity index 95% rename from suds/sax/document.py rename to txsuds/sax/document.py index 170858f..e994a2d 100644 --- a/suds/sax/document.py +++ b/txsuds/sax/document.py @@ -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, @@ -19,15 +19,16 @@ """ from logging import getLogger -from suds import * -from suds.sax import * -from suds.sax.element import Element +from txsuds import * +from txsuds.sax import * +from txsuds.sax.element import Element log = getLogger(__name__) + class Document(Element): """ simple document """ - + DECL = '' def __init__(self, root=None): @@ -45,7 +46,7 @@ def root(self): return self.children[0] else: return None - + def str(self): """ Get a string representation of this XML fragment. @@ -59,7 +60,7 @@ def str(self): s.append('\n') s.append(root.str()) return ''.join(s) - + def plain(self): """ Get a string representation of this XML fragment. @@ -75,6 +76,6 @@ def plain(self): def __str__(self): return unicode(self).encode('utf-8') - + def __unicode__(self): return self.str() \ No newline at end of file diff --git a/suds/sax/element.py b/txsuds/sax/element.py similarity index 96% rename from suds/sax/element.py rename to txsuds/sax/element.py index 9dec1f9..34628e9 100644 --- a/suds/sax/element.py +++ b/txsuds/sax/element.py @@ -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, @@ -19,17 +19,18 @@ """ from logging import getLogger -from suds import * -from suds.sax import * -from suds.sax.text import Text -from suds.sax.attribute import Attribute -import sys -if sys.version_info < (2, 4, 0): - from sets import Set as set - del sys +from txsuds import * +from txsuds.sax import * +from txsuds.sax.text import Text +from txsuds.sax.attribute import Attribute +import sys +if sys.version_info < (2, 4, 0): + from sets import Set as set + del sys log = getLogger(__name__) + class Element: """ An XML element object. @@ -58,11 +59,11 @@ class Element: 'eq': lambda a,b: a == b, 'startswith' : lambda a,b: a.startswith(b), 'endswith' : lambda a,b: a.endswith(b), - 'contains' : lambda a,b: b in a + 'contains' : lambda a,b: b in a } - + specialprefixes = { Namespace.xmlns[0] : Namespace.xmlns[1] } - + @classmethod def buildPath(self, parent, path): """ @@ -91,7 +92,7 @@ def __init__(self, name, parent=None, ns=None): @param ns: An optional namespace @type ns: (I{prefix}, I{name}) """ - + self.rename(name) self.expns = None self.nsprefixes = {} @@ -106,23 +107,23 @@ def __init__(self, name, parent=None, ns=None): self.parent = None self.children = [] self.applyns(ns) - + def rename(self, name): """ Rename the element. @param name: A new name for the element. - @type name: basestring + @type name: basestring """ if name is None: raise Exception('name (%s) not-valid' % name) else: self.prefix, self.name = splitPrefix(name) - + def setPrefix(self, p, u=None): """ Set the element namespace prefix. @param p: A new prefix for the element. - @type p: basestring + @type p: basestring @param u: A namespace URI to be mapped to the prefix. @type u: basestring @return: self @@ -143,7 +144,7 @@ def qname(self): return self.name else: return '%s:%s' % (self.prefix, self.name) - + def getRoot(self): """ Get the root (top) node of the tree. @@ -154,7 +155,7 @@ def getRoot(self): return self else: return self.parent.getRoot() - + def clone(self, parent=None): """ Deep clone of this element and children. @@ -171,7 +172,7 @@ def clone(self, parent=None): for item in self.nsprefixes.items(): root.addPrefix(item[0], item[1]) return root - + def detach(self): """ Detach from parent. @@ -184,7 +185,7 @@ def detach(self): self.parent.children.remove(self) self.parent = None return self - + def set(self, name, value): """ Set an attribute's value. @@ -200,7 +201,7 @@ def set(self, name, value): self.append(attr) else: attr.setValue(value) - + def unset(self, name): """ Unset (remove) an attribute. @@ -215,8 +216,8 @@ def unset(self, name): except: pass return self - - + + def get(self, name, ns=None, default=None): """ Get the value of an attribute by name. @@ -235,7 +236,7 @@ def get(self, name, ns=None, default=None): if attr is None or attr.value is None: return default else: - return attr.getValue() + return attr.getValue() def setText(self, value): """ @@ -250,7 +251,7 @@ def setText(self, value): else: self.text = Text(value) return self - + def getText(self, default=None): """ Get the element's L{Text} content with optional default @@ -263,7 +264,7 @@ def getText(self, default=None): return self.text else: return default - + def trim(self): """ Trim leading and trailing whitespace. @@ -273,7 +274,7 @@ def trim(self): if self.hasText(): self.text = self.text.trim() return self - + def hasText(self): """ Get whether the element has I{text} and that it is not an empty @@ -282,11 +283,11 @@ def hasText(self): @rtype: boolean """ return ( self.text is not None and len(self.text) ) - + def namespace(self): """ Get the element's namespace. - @return: The element's namespace by resolving the prefix, the explicit + @return: The element's namespace by resolving the prefix, the explicit namespace or the inherited namespace. @rtype: (I{prefix}, I{name}) """ @@ -294,10 +295,10 @@ def namespace(self): return self.defaultNamespace() else: return self.resolvePrefix(self.prefix) - + def defaultNamespace(self): """ - Get the default (unqualified namespace). + Get the default (unqualified namespace). This is the expns of the first node (looking up the tree) that has it set. @return: The namespace of a node when not qualified. @@ -310,7 +311,7 @@ def defaultNamespace(self): else: p = p.parent return Namespace.default - + def append(self, objects): """ Append the specified child based on whether it is an @@ -334,7 +335,7 @@ def append(self, objects): continue raise Exception('append %s not-valid' % child.__class__.__name__) return self - + def insert(self, objects, index=0): """ Insert an L{Element} content at the specified index. @@ -354,7 +355,7 @@ def insert(self, objects, index=0): else: raise Exception('append %s not-valid' % child.__class__.__name__) return self - + def remove(self, child): """ Remove the specified child element or attribute. @@ -368,7 +369,7 @@ def remove(self, child): if isinstance(child, Attribute): self.attributes.remove(child) return None - + def replaceChild(self, child, content): """ Replace I{child} with the specified I{content}. @@ -387,7 +388,7 @@ def replaceChild(self, child, content): self.children.insert(index, node.detach()) node.parent = self index += 1 - + def getAttribute(self, name, ns=None, default=None): """ Get an attribute by name and (optional) namespace @@ -433,7 +434,7 @@ def getChild(self, name, ns=None, default=None): if c.match(name, ns): return c return default - + def childAtPath(self, path): """ Get a child at I{path} where I{path} is a (/) separated @@ -472,7 +473,7 @@ def childrenAtPath(self, path): else: result = self.__childrenAtPath(parts) return result - + def getChildren(self, name=None, ns=None): """ Get a list of children by (optional) name and/or (optional) namespace. @@ -492,7 +493,7 @@ def getChildren(self, name=None, ns=None): else: ns = self.resolvePrefix(prefix) return [c for c in self.children if c.match(name, ns)] - + def detachChildren(self): """ Detach and return this element's children. @@ -504,7 +505,7 @@ def detachChildren(self): for child in detached: child.parent = None return detached - + def resolvePrefix(self, prefix, default=Namespace.default): """ Resolve the specified prefix to a namespace. The I{nsprefixes} is @@ -527,7 +528,7 @@ def resolvePrefix(self, prefix, default=Namespace.default): return (prefix, self.specialprefixes[prefix]) n = n.parent return default - + def addPrefix(self, p, u): """ Add or update a prefix mapping. @@ -540,10 +541,10 @@ def addPrefix(self, p, u): """ self.nsprefixes[p] = u return self - + def updatePrefix(self, p, u): """ - Update (redefine) a prefix mapping for the branch. + Update (redefine) a prefix mapping for the branch. @param p: A prefix. @type p: basestring @param u: A namespace URI. @@ -557,7 +558,7 @@ def updatePrefix(self, p, u): for c in self.children: c.updatePrefix(p, u) return self - + def clearPrefix(self, prefix): """ Clear the specified prefix from the prefix mappings. @@ -569,7 +570,7 @@ def clearPrefix(self, prefix): if prefix in self.nsprefixes: del self.nsprefixes[prefix] return self - + def findPrefix(self, uri, default=None): """ Find the first prefix that has been mapped to a namespace URI. @@ -589,7 +590,7 @@ def findPrefix(self, uri, default=None): for item in self.specialprefixes.items(): if item[1] == uri: prefix = item[0] - return prefix + return prefix if self.parent is not None: return self.parent.findPrefix(uri, default) else: @@ -619,7 +620,7 @@ def findPrefixes(self, uri, match='eq'): if self.parent is not None: result += self.parent.findPrefixes(uri, match) return result - + def promotePrefixes(self): """ Push prefix declarations up the tree as far as possible. Prefix @@ -643,7 +644,7 @@ def promotePrefixes(self): self.parent.nsprefixes[p] = u del self.nsprefixes[p] return self - + def refitPrefixes(self): """ Refit namespace qualification by replacing prefixes @@ -660,7 +661,7 @@ def refitPrefixes(self): self.prefix = None self.nsprefixes = {} return self - + def normalizePrefixes(self): """ Normalize the namespace prefixes. @@ -689,8 +690,8 @@ def isempty(self, content=True): return nocontent else: return ( nocontent and noattrs ) - - + + def isnil(self): """ Get whether the element is I{nil} as defined by having @@ -703,7 +704,7 @@ def isnil(self): return False else: return ( nilattr.getValue().lower() == 'true' ) - + def setnil(self, flag=True): """ Set this node to I{nil} as defined by having an @@ -720,7 +721,7 @@ def setnil(self, flag=True): if flag: self.text = None return self - + def applyns(self, ns): """ Apply the namespace to this node. If the prefix is I{None} then @@ -738,7 +739,7 @@ def applyns(self, ns): else: self.prefix = ns[0] self.nsprefixes[ns[0]] = ns[1] - + def str(self, indent=0): """ Get a string representation of this XML fragment. @@ -767,7 +768,7 @@ def str(self, indent=0): result.append('' % self.qname()) result = ''.join(result) return result - + def plain(self): """ Get a string representation of this XML fragment. @@ -816,7 +817,7 @@ def nsdeclarations(self): d = ' xmlns:%s="%s"' % (p, u) s.append(d) return ''.join(s) - + def match(self, name=None, ns=None): """ Match by (optional) name and/or (optional) namespace. @@ -836,7 +837,7 @@ def match(self, name=None, ns=None): else: byns = ( self.namespace()[1] == ns[1] ) return ( byname and byns ) - + def branch(self): """ Get a flattened representation of the branch. @@ -847,7 +848,7 @@ def branch(self): for c in self.children: branch += c.branch() return branch - + def ancestors(self): """ Get a list of ancestors. @@ -860,7 +861,7 @@ def ancestors(self): ancestors.append(p) p = p.parent return ancestors - + def walk(self, visitor): """ Walk the branch and call the visitor function @@ -873,7 +874,7 @@ def walk(self, visitor): for c in self.children: c.walk(visitor) return self - + def prune(self): """ Prune the branch of empty nodes. @@ -885,8 +886,8 @@ def prune(self): pruned.append(c) for p in pruned: self.children.remove(p) - - + + def __childrenAtPath(self, parts): result = [] node = self @@ -910,10 +911,10 @@ def __childrenAtPath(self, parts): ns = node.resolvePrefix(prefix) result = child.getChildren(leaf) return result - + def __len__(self): return len(self.children) - + def __getitem__(self, index): if isinstance(index, basestring): return self.get(index) @@ -922,7 +923,7 @@ def __getitem__(self, index): return self.children[index] else: return None - + def __setitem__(self, index, value): if isinstance(index, basestring): self.set(index, value) @@ -936,20 +937,20 @@ def __eq__(self, rhs): isinstance(rhs, Element) and \ self.name == rhs.name and \ self.namespace()[1] == rhs.namespace()[1] - + def __repr__(self): return \ 'Element (prefix=%s, name=%s)' % (self.prefix, self.name) - + def __str__(self): return unicode(self).encode('utf-8') - + def __unicode__(self): return self.str() - + def __iter__(self): return NodeIterator(self) - + class NodeIterator: """ @@ -957,9 +958,9 @@ class NodeIterator: @ivar pos: The current position @type pos: int @ivar children: A list of a child nodes. - @type children: [L{Element},..] + @type children: [L{Element},..] """ - + def __init__(self, parent): """ @param parent: An element to iterate. @@ -967,7 +968,7 @@ def __init__(self, parent): """ self.pos = 0 self.children = parent.children - + def next(self): """ Get the next child. @@ -995,7 +996,7 @@ class PrefixNormalizer: @ivar prefixes: A reverse dict of prefixes. @type prefixes: {u, p} """ - + @classmethod def apply(cls, node): """ @@ -1007,7 +1008,7 @@ def apply(cls, node): """ pn = PrefixNormalizer(node) return pn.refit() - + def __init__(self, node): """ @param node: A node to normalize. @@ -1017,7 +1018,7 @@ def __init__(self, node): self.branch = node.branch() self.namespaces = self.getNamespaces() self.prefixes = self.genPrefixes() - + def getNamespaces(self): """ Get the I{unique} set of namespaces referenced in the branch. @@ -1030,7 +1031,7 @@ def getNamespaces(self): s.add(n.expns) s = s.union(self.pset(n)) return s - + def pset(self, n): """ Convert the nodes nsprefixes into a set. @@ -1044,7 +1045,7 @@ def pset(self, n): if self.permit(ns): s.add(ns[1]) return s - + def genPrefixes(self): """ Generate a I{reverse} mapping of unique prefixes for all namespaces. @@ -1058,14 +1059,14 @@ def genPrefixes(self): prefixes[u] = p n += 1 return prefixes - + def refit(self): """ Refit (normalize) the prefixes in the node. """ self.refitNodes() self.refitMappings() - + def refitNodes(self): """ Refit (normalize) all of the nodes in the branch. @@ -1076,7 +1077,7 @@ def refitNodes(self): if self.permit(ns): n.prefix = self.prefixes[ns[1]] self.refitAttrs(n) - + def refitAttrs(self, n): """ Refit (normalize) all of the attributes in the node. @@ -1085,7 +1086,7 @@ def refitAttrs(self, n): """ for a in n.attributes: self.refitAddr(a) - + def refitAddr(self, a): """ Refit (normalize) the attribute. @@ -1097,7 +1098,7 @@ def refitAddr(self, a): if self.permit(ns): a.prefix = self.prefixes[ns[1]] self.refitValue(a) - + def refitValue(self, a): """ Refit (normalize) the attribute's value. @@ -1111,7 +1112,7 @@ def refitValue(self, a): u = ns[1] p = self.prefixes[u] a.setValue(':'.join((p, name))) - + def refitMappings(self): """ Refit (normalize) all of the nsprefix mappings. @@ -1121,7 +1122,7 @@ def refitMappings(self): n = self.node for u, p in self.prefixes.items(): n.addPrefix(p, u) - + def permit(self, ns): """ Get whether the I{ns} is to be normalized. @@ -1131,7 +1132,7 @@ def permit(self, ns): @rtype: boolean """ return not self.skip(ns) - + def skip(self, ns): """ Get whether the I{ns} is to B{not} be normalized. diff --git a/suds/sax/enc.py b/txsuds/sax/enc.py similarity index 99% rename from suds/sax/enc.py rename to txsuds/sax/enc.py index efc7274..8d3219c 100644 --- a/suds/sax/enc.py +++ b/txsuds/sax/enc.py @@ -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, @@ -30,14 +30,14 @@ class Encoder: @cvar special: A list of special characters @type special: [char] """ - + encodings = \ (( '&(?!(amp|lt|gt|quot|apos);)', '&' ),( '<', '<' ),( '>', '>' ),( '"', '"' ),("'", ''' )) decodings = \ (( '<', '<' ),( '>', '>' ),( '"', '"' ),( ''', "'" ),( '&', '&' )) special = \ ('&', '<', '>', '"', "'") - + def needsEncoding(self, s): """ Get whether string I{s} contains special characters. @@ -51,7 +51,7 @@ def needsEncoding(self, s): if c in s: return True return False - + def encode(self, s): """ Encode special characters found in string I{s}. @@ -64,7 +64,7 @@ def encode(self, s): for x in self.encodings: s = re.sub(x[0], x[1], s) return s - + def decode(self, s): """ Decode special characters encodings found in string I{s}. diff --git a/suds/sax/parser.py b/txsuds/sax/parser.py similarity index 94% rename from suds/sax/parser.py rename to txsuds/sax/parser.py index 69f871b..b7438b0 100644 --- a/suds/sax/parser.py +++ b/txsuds/sax/parser.py @@ -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, @@ -27,13 +27,13 @@ """ from logging import getLogger -import suds.metrics -from suds import * -from suds.sax import * -from suds.sax.document import Document -from suds.sax.element import Element -from suds.sax.text import Text -from suds.sax.attribute import Attribute +from txsuds import metrics +from txsuds import * +from txsuds.sax import * +from txsuds.sax.document import Document +from txsuds.sax.element import Element +from txsuds.sax.text import Text +from txsuds.sax.attribute import Attribute from xml.sax import make_parser, InputSource, ContentHandler from xml.sax.handler import feature_external_ges from cStringIO import StringIO @@ -43,10 +43,10 @@ class Handler(ContentHandler): """ sax hanlder """ - + def __init__(self): self.nodes = [Document()] - + def startElement(self, name, attrs): top = self.top() node = Element(unicode(name), parent=top) @@ -60,7 +60,7 @@ def startElement(self, name, attrs): node.charbuffer = [] top.append(node) self.push(node) - + def mapPrefix(self, node, attribute): skip = False if attribute.name == 'xmlns': @@ -72,7 +72,7 @@ def mapPrefix(self, node, attribute): node.nsprefixes[prefix] = unicode(attribute.value) skip = True return skip - + def endElement(self, name): name = unicode(name) current = self.top() @@ -86,7 +86,7 @@ def endElement(self, name): self.pop() else: raise Exception('malformed document') - + def characters(self, content): text = unicode(content) node = self.top() @@ -98,14 +98,14 @@ def push(self, node): def pop(self): return self.nodes.pop() - + def top(self): return self.nodes[len(self.nodes)-1] class Parser: """ SAX Parser """ - + @classmethod def saxparser(cls): p = make_parser() @@ -113,7 +113,7 @@ def saxparser(cls): h = Handler() p.setContentHandler(h) return (p, h) - + def parse(self, file=None, string=None): """ SAX parse XML text. diff --git a/suds/sax/text.py b/txsuds/sax/text.py similarity index 96% rename from suds/sax/text.py rename to txsuds/sax/text.py index 0d58ee8..a96ae4d 100644 --- a/suds/sax/text.py +++ b/txsuds/sax/text.py @@ -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, @@ -18,8 +18,8 @@ Contains XML text classes. """ -from suds import * -from suds.sax import * +from txsuds import * +from txsuds.sax import * class Text(unicode): @@ -31,11 +31,11 @@ class Text(unicode): @type escaped: bool """ __slots__ = ('lang', 'escaped',) - + @classmethod def __valid(cls, *args): return ( len(args) and args[0] is not None ) - + def __new__(cls, *args, **kwargs): if cls.__valid(*args): lang = kwargs.pop('lang', None) @@ -46,7 +46,7 @@ def __new__(cls, *args, **kwargs): else: result = None return result - + def escape(self): """ Encode (escape) special XML characters. @@ -58,7 +58,7 @@ def escape(self): escaped = ( post != self ) return Text(post, lang=self.lang, escaped=escaped) return self - + def unescape(self): """ Decode (unescape) special XML characters. @@ -69,18 +69,18 @@ def unescape(self): post = sax.encoder.decode(self) return Text(post, lang=self.lang) return self - + def trim(self): post = self.strip() return Text(post, lang=self.lang, escaped=self.escaped) - + def __add__(self, other): joined = u''.join((self, other)) result = Text(joined, lang=self.lang, escaped=self.escaped) if isinstance(other, Text): result.escaped = ( self.escaped or other.escaped ) return result - + def __repr__(self): s = [self] if self.lang is not None: @@ -88,18 +88,18 @@ def __repr__(self): if self.escaped: s.append(' ') return ''.join(s) - + def __getstate__(self): state = {} for k in self.__slots__: state[k] = getattr(self, k) return state - + def __setstate__(self, state): for k in self.__slots__: setattr(self, k, state[k]) - - + + class Raw(Text): """ Raw text which is not XML escaped. @@ -107,10 +107,10 @@ class Raw(Text): """ def escape(self): return self - + def unescape(self): return self - + def __add__(self, other): joined = u''.join((self, other)) return Raw(joined, lang=self.lang) diff --git a/suds/servicedefinition.py b/txsuds/servicedefinition.py similarity index 97% rename from suds/servicedefinition.py rename to txsuds/servicedefinition.py index 81b5a0d..4972fdd 100644 --- a/suds/servicedefinition.py +++ b/txsuds/servicedefinition.py @@ -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, @@ -19,12 +19,13 @@ """ from logging import getLogger -from suds import * -import suds.metrics as metrics -from suds.sax import Namespace +from txsuds import * +import txsuds.metrics as metrics +from txsuds.sax import Namespace log = getLogger(__name__) + class ServiceDefinition: """ A service definition provides an object used to generate a textual description @@ -38,9 +39,9 @@ class ServiceDefinition: @ivar prefixes: A list of remapped prefixes. @type prefixes: [(prefix,uri),..] @ivar types: A list of type definitions - @type types: [I{Type},..] + @type types: [I{Type},..] """ - + def __init__(self, wsdl, service): """ @param wsdl: A wsdl object @@ -59,7 +60,7 @@ def __init__(self, wsdl, service): self.publictypes() self.getprefixes() self.pushprefixes() - + def pushprefixes(self): """ Add our prefixes to the wsdl so that when users invoke methods @@ -87,7 +88,7 @@ def addports(self): metrics.log.debug("method '%s' created: %s", m.name, timer) p[1].sort() timer.stop() - + def findport(self, port): """ Find and return a port tuple for the specified port. @@ -102,7 +103,7 @@ def findport(self, port): p = (port, []) self.ports.append(p) return p - + def getprefixes(self): """ Add prefixes foreach namespace referenced by parameter types. @@ -127,7 +128,7 @@ def getprefixes(self): p = self.nextprefix() ns = (p, u) self.prefixes.append(ns) - + def paramtypes(self): """ get all parameter types """ for m in [p[1] for p in self.ports]: @@ -136,7 +137,7 @@ def paramtypes(self): if pd[1] in self.params: continue item = (pd[1], pd[1].resolve()) self.params.append(item) - + def publictypes(self): """ get all public types """ for t in self.wsdl.schema.types.values(): @@ -146,7 +147,7 @@ def publictypes(self): self.types.append(item) tc = lambda x,y: cmp(x[0].name, y[0].name) self.types.sort(cmp=tc) - + def nextprefix(self): """ Get the next available prefix. This means a prefix starting with 'ns' with @@ -160,7 +161,7 @@ def nextprefix(self): if p not in used: return p raise Exception('prefixes exhausted') - + def getprefix(self, u): """ Get the prefix for the specified namespace (uri) @@ -174,7 +175,7 @@ def getprefix(self, u): for ns in self.prefixes: if u == ns[1]: return ns[0] raise Exception('ns (%s) not mapped' % u) - + def xlate(self, type): """ Get a (namespace) translated I{qualified} name for specified type. @@ -192,7 +193,7 @@ def xlate(self, type): return name prefix = self.getprefix(ns[1]) return ':'.join((prefix, name)) - + def description(self): """ Get a textual description of the service for which this object represents. @@ -236,10 +237,10 @@ def description(self): s.append(self.xlate(t[0])) s.append('\n\n') return ''.join(s) - + def __str__(self): return unicode(self).encode('utf-8') - + def __unicode__(self): try: return self.description() diff --git a/suds/serviceproxy.py b/txsuds/serviceproxy.py similarity index 95% rename from suds/serviceproxy.py rename to txsuds/serviceproxy.py index 6e71050..2401110 100644 --- a/suds/serviceproxy.py +++ b/txsuds/serviceproxy.py @@ -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, @@ -21,17 +21,17 @@ """ from logging import getLogger -from suds import * -from suds.client import Client +from txsuds import * +from txsuds.client import Client log = getLogger(__name__) class ServiceProxy(object): - - """ + + """ A lightweight soap based web service proxy. - @ivar __client__: A client. + @ivar __client__: A client. Everything is delegated to the 2nd generation API. @type __client__: L{Client} @note: Deprecated, replaced by L{Client}. @@ -51,7 +51,7 @@ def __init__(self, url, **kwargs): """ client = Client(url, **kwargs) self.__client__ = client - + def get_instance(self, name): """ Get an instance of a WSDL type by name @@ -61,7 +61,7 @@ def get_instance(self, name): @rtype: L{sudsobject.Object} """ return self.__client__.factory.create(name) - + def get_enum(self, name): """ Get an instance of an enumeration defined in the WSDL by name. @@ -71,13 +71,13 @@ def get_enum(self, name): @rtype: L{sudsobject.Object} """ return self.__client__.factory.create(name) - + def __str__(self): return str(self.__client__) - + def __unicode__(self): return unicode(self.__client__) - + def __getattr__(self, name): builtin = name.startswith('__') and name.endswith('__') if builtin: diff --git a/suds/soaparray.py b/txsuds/soaparray.py similarity index 92% rename from suds/soaparray.py rename to txsuds/soaparray.py index 04847d5..9847e99 100644 --- a/suds/soaparray.py +++ b/txsuds/soaparray.py @@ -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, @@ -19,10 +19,9 @@ soap (section 5) encoded arrays. """ -from suds import * -from logging import getLogger -from suds.xsd.sxbasic import Factory as SXFactory -from suds.xsd.sxbasic import Attribute as SXAttribute +from txsuds import * +from txsuds.xsd.sxbasic import Factory as SXFactory +from txsuds.xsd.sxbasic import Attribute as SXAttribute class Attribute(SXAttribute): @@ -43,12 +42,12 @@ def __init__(self, schema, root, aty): self.aty = aty[:-2] else: self.aty = aty - + def autoqualified(self): aqs = SXAttribute.autoqualified(self) aqs.append('aty') return aqs - + def description(self): d = SXAttribute.description(self) d = d+('aty',) diff --git a/suds/store.py b/txsuds/store.py similarity index 98% rename from suds/store.py rename to txsuds/store.py index 85e0943..19e5c4b 100644 --- a/suds/store.py +++ b/txsuds/store.py @@ -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, @@ -32,13 +32,13 @@ encoding = \ """ - + 'root' can be used to distinguish serialization roots from other elements that are present in a serialization but are not roots of - a serialized value graph + a serialized value graph @@ -51,7 +51,7 @@ - Attributes common to all elements that function as accessors or + Attributes common to all elements that function as accessors or represent independent (multi-ref) values. The href attribute is intended to be used in a manner like CONREF. That is, the element content should be empty iff the href attribute appears @@ -63,26 +63,26 @@ - + - + - + - + - - - - + + + + - + @@ -94,18 +94,18 @@ - 'Array' is a complex type for accessors identified by position + 'Array' is a complex type for accessors identified by position - + - - + @@ -117,7 +117,7 @@ - + @@ -126,7 +126,7 @@ - @@ -157,7 +157,7 @@ - + @@ -221,7 +221,7 @@ - + @@ -285,7 +285,7 @@ - + @@ -543,13 +543,13 @@ class DocumentStore: @cvar store: The mapping of URL location to documents. @type store: dict """ - + protocol = 'suds' - + store = { 'schemas.xmlsoap.org/soap/encoding/' : encoding } - + def open(self, url): """ Open a document at the specified url. @@ -563,7 +563,7 @@ def open(self, url): return self.find(location) else: return None - + def find(self, location): """ Find the specified location in the store. @@ -578,7 +578,7 @@ def find(self, location): except: reason = 'location "%s" not in document store' % location raise Exception, reason - + def split(self, url): """ Split the url into I{protocol} and I{location} diff --git a/suds/sudsobject.py b/txsuds/sudsobject.py similarity index 96% rename from suds/sudsobject.py rename to txsuds/sudsobject.py index 1f6168d..4f54f6e 100644 --- a/suds/sudsobject.py +++ b/txsuds/sudsobject.py @@ -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, @@ -21,7 +21,7 @@ """ from logging import getLogger -from suds import * +from txsuds import * from new import classobj log = getLogger(__name__) @@ -86,11 +86,11 @@ def footprint(sobject): n +=1 return n - + class Factory: - + cache = {} - + @classmethod def subclass(cls, name, bases, dict={}): if not isinstance(bases, tuple): @@ -102,7 +102,7 @@ def subclass(cls, name, bases, dict={}): subclass = classobj(name, bases, dict) cls.cache[key] = subclass return subclass - + @classmethod def object(cls, classname=None, dict={}): if classname is not None: @@ -113,11 +113,11 @@ def object(cls, classname=None, dict={}): for a in dict.items(): setattr(inst, a[0], a[1]) return inst - + @classmethod def metadata(cls): return Metadata() - + @classmethod def property(cls, name, value=None): subclass = cls.subclass(name, Property) @@ -137,7 +137,7 @@ def __setattr__(self, name, value): name not in self.__keylist__: self.__keylist__.append(name) self.__dict__[name] = value - + def __delattr__(self, name): try: del self.__dict__[name] @@ -152,25 +152,25 @@ def __getitem__(self, name): if isinstance(name, int): name = self.__keylist__[int(name)] return getattr(self, name) - + def __setitem__(self, name, value): setattr(self, name, value) - + def __iter__(self): return Iter(self) def __len__(self): return len(self.__keylist__) - + def __contains__(self, name): return name in self.__keylist__ - + def __repr__(self): return str(self) def __str__(self): return unicode(self).encode('utf-8') - + def __unicode__(self): return self.__printer__.tostr(self) @@ -192,7 +192,7 @@ def next(self): v = getattr(self.sobject, k) return (k, v) raise StopIteration() - + def __keylist(self, sobject): keylist = sobject.__keylist__ try: @@ -202,13 +202,13 @@ def __keylist(self, sobject): if not ordered.issuperset(keyset): log.debug( '%s must be superset of %s, ordering ignored', - keylist, + keylist, ordering) raise KeyError() return ordering except: return keylist - + def __iter__(self): return self @@ -225,31 +225,31 @@ def __init__(self, name): md = self.__metadata__ md.facade = name - + class Property(Object): def __init__(self, value): Object.__init__(self) self.value = value - + def items(self): for item in self: if item[0] != 'value': yield item - + def get(self): return self.value - + def set(self, value): self.value = value return self class Printer: - """ + """ Pretty printing of a Object object. """ - + @classmethod def indent(cls, n): return '%*s'%(n*3,' ') @@ -257,7 +257,7 @@ def tostr(self, object, indent=-2): """ get s string representation of object """ history = [] return self.process(object, history, indent) - + def process(self, object, h, n=0, nl=False): """ print object using the specified indent (n) and newline (nl). """ if object is None: @@ -280,7 +280,7 @@ def process(self, object, h, n=0, nl=False): if isinstance(object, basestring): return '"%s"' % tostr(object) return '%s' % tostr(object) - + def print_object(self, d, h, n, nl=False): """ print complex using the specified indent (n) and newline (nl). """ s = [] @@ -310,7 +310,7 @@ def print_object(self, d, h, n, nl=False): item = self.unwrap(d, item) s.append('\n') s.append(self.indent(n+1)) - if isinstance(item[1], (list,tuple)): + if isinstance(item[1], (list,tuple)): s.append(item[0]) s.append('[]') else: @@ -322,7 +322,7 @@ def print_object(self, d, h, n, nl=False): s.append('}') h.pop() return ''.join(s) - + def print_dictionary(self, d, h, n, nl=False): """ print complex using the specified indent (n) and newline (nl). """ if d in h: return '{}...' @@ -335,7 +335,7 @@ def print_dictionary(self, d, h, n, nl=False): for item in d.items(): s.append('\n') s.append(self.indent(n+1)) - if isinstance(item[1], (list,tuple)): + if isinstance(item[1], (list,tuple)): s.append(tostr(item[0])) s.append('[]') else: @@ -360,7 +360,7 @@ def print_collection(self, c, h, n): s.append(',') h.pop() return ''.join(s) - + def unwrap(self, d, item): """ translate (unwrap) using an optional wrapper function """ nopt = ( lambda x: x ) @@ -375,7 +375,7 @@ def unwrap(self, d, item): except: pass return item - + def exclude(self, d, item): """ check metadata for excluded items """ try: @@ -384,7 +384,7 @@ def exclude(self, d, item): if pmd is None: return False excludes = getattr(pmd, 'excludes', []) - return ( item[0] in excludes ) + return ( item[0] in excludes ) except: pass return False \ No newline at end of file diff --git a/suds/transport/__init__.py b/txsuds/transport/__init__.py similarity index 97% rename from suds/transport/__init__.py rename to txsuds/transport/__init__.py index e1e00d7..cfb6035 100644 --- a/suds/transport/__init__.py +++ b/txsuds/transport/__init__.py @@ -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, @@ -25,6 +25,7 @@ def __init__(self, reason, httpcode, fp=None): self.httpcode = httpcode self.fp = fp + class Request: """ A transport request @@ -46,7 +47,7 @@ def __init__(self, url, message=None): self.url = url self.headers = {} self.message = message - + def __str__(self): s = [] s.append('URL:%s' % self.url) @@ -79,7 +80,7 @@ def __init__(self, code, headers, message): self.code = code self.headers = headers self.message = message - + def __str__(self): s = [] s.append('CODE: %s' % self.code) @@ -93,15 +94,15 @@ class Transport: """ The transport I{interface}. """ - + def __init__(self): """ Constructor. """ - from suds.transport.options import Options + from txsuds.transport.options import Options self.options = Options() del Options - + def open(self, request): """ Open the url in the specified request. @@ -112,7 +113,7 @@ def open(self, request): @raise TransportError: On all transport errors. """ raise Exception('not-implemented') - + def send(self, request): """ Send soap message. Implementations are expected to handle: diff --git a/suds/transport/http.py b/txsuds/transport/http.py similarity index 98% rename from suds/transport/http.py rename to txsuds/transport/http.py index f5d7e0f..fbcd097 100644 --- a/suds/transport/http.py +++ b/txsuds/transport/http.py @@ -21,12 +21,12 @@ import urllib2 as u2 import base64 import socket -from suds.transport import * -from suds.properties import Unskin -from urlparse import urlparse +from txsuds.transport import * +from txsuds.properties import Unskin from cookielib import CookieJar from logging import getLogger + log = getLogger(__name__) diff --git a/suds/transport/https.py b/txsuds/transport/https.py similarity index 95% rename from suds/transport/https.py rename to txsuds/transport/https.py index ed23fd5..dc61efb 100644 --- a/suds/transport/https.py +++ b/txsuds/transport/https.py @@ -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, @@ -19,8 +19,8 @@ """ import urllib2 as u2 -from suds.transport import * -from suds.transport.http import HttpTransport +from txsuds.transport import * +from txsuds.transport.http import HttpTransport from logging import getLogger log = getLogger(__name__) @@ -34,7 +34,7 @@ class HttpAuthenticated(HttpTransport): @ivar pm: The password manager. @ivar handler: The authentication handler. """ - + def __init__(self, **kwargs): """ @param kwargs: Keyword arguments. @@ -54,31 +54,31 @@ def __init__(self, **kwargs): """ HttpTransport.__init__(self, **kwargs) self.pm = u2.HTTPPasswordMgrWithDefaultRealm() - + def open(self, request): self.addcredentials(request) return HttpTransport.open(self, request) - + def send(self, request): self.addcredentials(request) return HttpTransport.send(self, request) - + def addcredentials(self, request): credentials = self.credentials() if not (None in credentials): u = credentials[0] p = credentials[1] self.pm.add_password(None, request.url, u, p) - + def credentials(self): return (self.options.username, self.options.password) - + def u2handlers(self): handlers = HttpTransport.u2handlers(self) handlers.append(u2.HTTPBasicAuthHandler(self.pm)) return handlers - - + + class WindowsHttpAuthenticated(HttpAuthenticated): """ Provides Windows (NTLM) http authentication. @@ -86,9 +86,9 @@ class WindowsHttpAuthenticated(HttpAuthenticated): @ivar handler: The authentication handler. @author: Christopher Bess """ - + def u2handlers(self): - # try to import ntlm support + # try to import ntlm support try: from ntlm import HTTPNtlmAuthHandler except ImportError: diff --git a/suds/transport/options.py b/txsuds/transport/options.py similarity index 98% rename from suds/transport/options.py rename to txsuds/transport/options.py index 9939de7..05e4f51 100644 --- a/suds/transport/options.py +++ b/txsuds/transport/options.py @@ -19,8 +19,8 @@ """ -from suds.transport import * -from suds.properties import * +from txsuds.transport import * +from txsuds.properties import * class Options(Skin): diff --git a/suds/transport/twisted_transport.py b/txsuds/transport/twisted_transport.py similarity index 63% rename from suds/transport/twisted_transport.py rename to txsuds/transport/twisted_transport.py index 744ea50..6c8929c 100644 --- a/suds/transport/twisted_transport.py +++ b/txsuds/transport/twisted_transport.py @@ -5,19 +5,17 @@ log = logging.getLogger(__name__) -import twisted.internet from twisted.internet import defer, reactor from twisted.internet.endpoints import TCP4ClientEndpoint -from twisted.internet.protocol import ClientCreator, ClientFactory, Protocol +from twisted.internet.protocol import Protocol from twisted.internet.ssl import CertificateOptions -from twisted.web.client import Agent, WebClientContextFactory, _parse +from twisted.web.client import Agent, ProxyAgent, WebClientContextFactory from twisted.web.http_headers import Headers from twisted.web.iweb import IBodyProducer -from twisted.web._newclient import HTTP11ClientProtocol, Request from OpenSSL import crypto from zope.interface import implements -from suds.transport import Reply, Transport +from txsuds.transport import Reply, Transport class StringResponseConsumer(Protocol): @@ -76,61 +74,6 @@ def stopProducing(self): pass -class NewAgent(Agent): - """ - @ivar _connectTimeout: If not C{None}, the timeout passed to C{connectTCP} - or C{connectSSL} for specifying the connection timeout. - - @ivar _bindAddress: If not C{None}, the address passed to C{connectTCP} or - C{connectSSL} for specifying the local address to bind to. - - @note: This class was added to add support for connection timeouts to the - Agent class in Twisted 11.0.0. It was based of a change made in - Twisted that is still pending a release. Once a new version of Twisted - is released, this class can be removed. - - http://twistedmatrix.com/trac/changeset/32244 - """ - def __init__(self, reactor, contextFactory = WebClientContextFactory(), - connectTimeout = None, bindAddress = None): - Agent.__init__(self, reactor, contextFactory) - - self._connectTimeout = connectTimeout - self._bindAddress = bindAddress - - def _connect(self, scheme, host, port): - """ - Connect to the given host and port, using a transport selected based on - scheme. - - @param scheme: A string like C{'http'} or C{'https'} (the only two - supported values) to use to determine how to establish the - connection. - - @param host: A C{str} giving the hostname which will be connected to in - order to issue a request. - - @param port: An C{int} giving the port number the connection will be - on. - - @return: A L{Deferred} which fires with a connected instance of - C{self._protocol}. - """ - cc = ClientCreator(self._reactor, self._protocol) - kwargs = {} - if self._connectTimeout is not None: - kwargs['timeout'] = self._connectTimeout - kwargs['bindAddress'] = self._bindAddress - if scheme == 'http': - d = cc.connectTCP(host, port, **kwargs) - elif scheme == 'https': - d = cc.connectSSL(host, port, self._wrapContextFactory(host, port), - **kwargs) - else: - d = defer.fail(SchemeNotSupported("Unsupported scheme: %r" % (scheme,))) - return d - - class ContextFactory(CertificateOptions, WebClientContextFactory): """ Custom context facotry that allows any hostname and port combination. @@ -142,63 +85,6 @@ def getContext(self, hostname, port): return CertificateOptions.getContext(self) -class _HTTP11ClientFactory(ClientFactory): - """ - A simple factory for L{HTTP11ClientProtocol}, used by L{ProxyAgent}. - - @since: 11.1 - """ - protocol = HTTP11ClientProtocol - - -class ProxyAgent(Agent): - """ - An HTTP agent able to cross HTTP proxies. - - @ivar _factory: The factory used to connect to the proxy. - - @ivar _proxyEndpoint: The endpoint used to connect to the proxy, passing - the factory. - - @since: 11.1 - """ - - _factory = _HTTP11ClientFactory - - def __init__(self, endpoint): - self._proxyEndpoint = endpoint - - def _connect(self, scheme, host, port): - """ - Ignore the connection to the expected host, and connect to the proxy - instead. - """ - return self._proxyEndpoint.connect(self._factory()) - - def request(self, method, uri, headers=None, bodyProducer=None): - """ - Issue a new request via the configured proxy. - """ - scheme, host, port, path = _parse(uri) - request_path = uri - - d = self._connect(scheme, host, port) - - if headers is None: - headers = Headers() - if not headers.hasHeader('host'): - # This is a lot of copying. It might be nice if there were a bit - # less. - headers = Headers(dict(headers.getAllRawHeaders())) - headers.addRawHeader( - 'host', self._computeHostValue(scheme, host, port)) - def cbConnected(proto): - # NOTE: For the proxy case the path should be the full URI. - return proto.request(Request(method, request_path, headers, bodyProducer)) - d.addCallback(cbConnected) - return d - - class TwistedTransport(Transport): """ Custom transport that uses the Twisted REST client. @@ -208,7 +94,7 @@ def __init__(self): Constructor. """ Transport.__init__(self) - from suds.transport.options import Options + from txsuds.transport.options import Options self.options = Options() del Options self._contextFactory = None @@ -279,8 +165,8 @@ def _request(self, request, method): timeout = self.options.timeout) agent = ProxyAgent(endpoint) else: - agent = NewAgent(reactor, self.contextFactory, - connectTimeout = self.options.timeout) + agent = Agent(reactor, self.contextFactory, + connectTimeout = self.options.timeout) url = request.url.encode("utf-8") producer = StringProducer(request.message or "") diff --git a/suds/umx/__init__.py b/txsuds/umx/__init__.py similarity index 97% rename from suds/umx/__init__.py rename to txsuds/umx/__init__.py index 9d06b40..f81e57c 100644 --- a/suds/umx/__init__.py +++ b/txsuds/umx/__init__.py @@ -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, @@ -19,8 +19,7 @@ unmarshalling (XML). """ -from suds.sudsobject import Object - +from txsuds.sudsobject import Object class Content(Object): @@ -32,7 +31,7 @@ class Content(Object): @ivar text: The (optional) content (xml) text. @type text: basestring """ - + extensions = [] def __init__(self, node, **kwargs): diff --git a/suds/umx/attrlist.py b/txsuds/umx/attrlist.py similarity index 94% rename from suds/umx/attrlist.py rename to txsuds/umx/attrlist.py index 3694327..c417c04 100644 --- a/suds/umx/attrlist.py +++ b/txsuds/umx/attrlist.py @@ -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, @@ -18,9 +18,9 @@ Provides filtered attribute list classes. """ -from suds import * -from suds.umx import * -from suds.sax import Namespace +from txsuds import * +from txsuds.umx import * +from txsuds.sax import Namespace class AttrList: @@ -37,7 +37,7 @@ def __init__(self, attributes): @type attributes: list """ self.raw = attributes - + def real(self): """ Get list of I{real} attributes which exclude xs and xml attributes. @@ -47,18 +47,18 @@ def real(self): for a in self.raw: if self.skip(a): continue yield a - + def rlen(self): """ Get the number of I{real} attributes which exclude xs and xml attributes. - @return: A count of I{real} attributes. + @return: A count of I{real} attributes. @rtype: L{int} """ n = 0 for a in self.real(): n += 1 return n - + def lang(self): """ Get list of I{filtered} attributes which exclude xs. diff --git a/suds/umx/basic.py b/txsuds/umx/basic.py similarity index 93% rename from suds/umx/basic.py rename to txsuds/umx/basic.py index cdc1e66..1a95270 100644 --- a/suds/umx/basic.py +++ b/txsuds/umx/basic.py @@ -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, @@ -19,16 +19,16 @@ """ from logging import getLogger -from suds import * -from suds.umx import * -from suds.umx.core import Core +from txsuds import * +from txsuds.umx import * +from txsuds.umx.core import Core class Basic(Core): """ A object builder (unmarshaller). """ - + def process(self, node): """ Process an object graph representation of the xml I{node}. diff --git a/suds/umx/core.py b/txsuds/umx/core.py similarity index 96% rename from suds/umx/core.py rename to txsuds/umx/core.py index 07d33c4..868917c 100644 --- a/suds/umx/core.py +++ b/txsuds/umx/core.py @@ -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, @@ -19,11 +19,11 @@ """ from logging import getLogger -from suds import * -from suds.umx import * -from suds.umx.attrlist import AttrList -from suds.sax.text import Text -from suds.sudsobject import Factory, merge +from txsuds import * +from txsuds.umx import * +from txsuds.umx.attrlist import AttrList +from txsuds.sax.text import Text +from txsuds.sudsobject import Factory, merge log = getLogger(__name__) @@ -35,7 +35,7 @@ class Core: The abstract XML I{node} unmarshaller. This class provides the I{core} unmarshalling functionality. """ - + def process(self, content): """ Process an object graph representation of the xml I{node}. @@ -46,7 +46,7 @@ def process(self, content): """ self.reset() return self.append(content) - + def append(self, content): """ Process the specified node and convert the XML document into @@ -64,14 +64,14 @@ def append(self, content): self.append_text(content) self.end(content) return self.postprocess(content) - + def postprocess(self, content): """ Perform final processing of the resulting data structure as follows: - Mixed values (children and text) will have a result of the I{content.node}. - Simi-simple values (attributes, no-children and text) will have a result of a property object. - - Simple values (no-attributes, no-children with text nodes) will have a string + - Simple values (no-attributes, no-children with text nodes) will have a string result equal to the value of the content.node.getText(). @param content: The current content being unmarshalled. @type content: L{Content} @@ -101,7 +101,7 @@ def postprocess(self, content): return Text(content.text, lang=lang) else: return content.text - + def append_attributes(self, content): """ Append attribute nodes into L{Content.data}. @@ -114,7 +114,7 @@ def append_attributes(self, content): name = attr.name value = attr.value self.append_attribute(name, value, content) - + def append_attribute(self, name, value, content): """ Append an attribute name/value into L{Content.data}. @@ -128,7 +128,7 @@ def append_attribute(self, name, value, content): key = name key = '_%s' % reserved.get(key, key) setattr(content.data, key, value) - + def append_children(self, content): """ Append child nodes into L{Content.data} @@ -153,7 +153,7 @@ def append_children(self, content): setattr(content.data, key, [cval,]) else: setattr(content.data, key, cval) - + def append_text(self, content): """ Append text nodes into L{Content.data} @@ -162,7 +162,7 @@ def append_text(self, content): """ if content.node.hasText(): content.text = content.node.getText() - + def reset(self): pass @@ -176,7 +176,7 @@ def start(self, content): @rtype: L{Object} """ content.data = Factory.object(content.node.name) - + def end(self, content): """ Processing on I{node} has ended. @@ -184,7 +184,7 @@ def end(self, content): @type content: L{Content} """ pass - + def bounded(self, content): """ Get whether the content is bounded (not a list). @@ -194,7 +194,7 @@ def bounded(self, content): @rtype: boolean '""" return ( not self.unbounded(content) ) - + def unbounded(self, content): """ Get whether the object is unbounded (a list). @@ -204,7 +204,7 @@ def unbounded(self, content): @rtype: boolean '""" return False - + def nillable(self, content): """ Get whether the object is nillable. diff --git a/suds/umx/encoded.py b/txsuds/umx/encoded.py similarity index 96% rename from suds/umx/encoded.py rename to txsuds/umx/encoded.py index afe7374..7246af5 100644 --- a/suds/umx/encoded.py +++ b/txsuds/umx/encoded.py @@ -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, @@ -19,10 +19,10 @@ """ from logging import getLogger -from suds import * -from suds.umx import * -from suds.umx.typed import Typed -from suds.sax import splitPrefix, Namespace +from txsuds import * +from txsuds.umx import * +from txsuds.umx.typed import Typed +from txsuds.sax import splitPrefix, Namespace log = getLogger(__name__) @@ -45,7 +45,7 @@ def start(self, content): # self.setaty(content) Typed.start(self, content) - + def end(self, content): # # Squash soap encoded arrays into python lists. This is @@ -56,7 +56,7 @@ def end(self, content): if aty is not None: self.promote(content) return Typed.end(self, content) - + def postprocess(self, content): # # Ensure proper rendering of empty arrays. @@ -65,7 +65,7 @@ def postprocess(self, content): return Typed.postprocess(self, content) else: return content.data - + def setaty(self, content): """ Grab the (aty) soap-enc:arrayType and attach it to the @@ -87,11 +87,11 @@ def setaty(self, content): else: pass # (2) dimensional array return self - + def applyaty(self, content, xty): """ Apply the type referenced in the I{arrayType} to the content - (child nodes) of the array. Each element (node) in the array + (child nodes) of the array. Each element (node) in the array that does not have an explicit xsi:type attribute is given one based on the I{arrayType}. @param content: An array content. @@ -115,7 +115,7 @@ def applyaty(self, content, xty): def promote(self, content): """ Promote (replace) the content.data with the first attribute - of the current content.data that is a I{list}. Note: the + of the current content.data that is a I{list}. Note: the content.data may be empty or contain only _x attributes. In either case, the content.data is assigned an empty list. @param content: An array content. diff --git a/suds/umx/typed.py b/txsuds/umx/typed.py similarity index 95% rename from suds/umx/typed.py rename to txsuds/umx/typed.py index f272a25..e4d42be 100644 --- a/suds/umx/typed.py +++ b/txsuds/umx/typed.py @@ -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, @@ -19,11 +19,11 @@ """ from logging import getLogger -from suds import * -from suds.umx import * -from suds.umx.core import Core -from suds.resolver import NodeResolver, Frame -from suds.sudsobject import Factory +from txsuds import * +from txsuds.umx import * +from txsuds.umx.core import Core +from txsuds.resolver import NodeResolver, Frame +from txsuds.sudsobject import Factory log = getLogger(__name__) @@ -43,14 +43,14 @@ class Typed(Core): @ivar resolver: A schema type resolver. @type resolver: L{NodeResolver} """ - + def __init__(self, schema): """ @param schema: A schema object. @type schema: L{xsd.schema.Schema} """ self.resolver = NodeResolver(schema) - + def process(self, node, type): """ Process an object graph representation of the xml L{node}. @@ -68,7 +68,7 @@ def process(self, node, type): def reset(self): log.debug('reset') self.resolver.reset() - + def start(self, content): # # Resolve to the schema type; build an object and setup metadata. @@ -91,18 +91,18 @@ def start(self, content): content.data = Factory.object(cls_name) md = content.data.__metadata__ md.sxtype = real - + def end(self, content): self.resolver.pop() - + def unbounded(self, content): return content.type.unbounded() - + def nillable(self, content): resolved = content.type.resolve() return ( content.type.nillable or \ (resolved.builtin() and resolved.nillable ) ) - + def append_attribute(self, name, value, content): """ Append an attribute name/value into L{Content.data}. @@ -119,7 +119,7 @@ def append_attribute(self, name, value, content): else: value = self.translated(value, type) Core.append_attribute(self, name, value, content) - + def append_text(self, content): """ Append text nodes into L{Content.data} @@ -131,7 +131,7 @@ def append_text(self, content): Core.append_text(self, content) known = self.resolver.top().resolved content.text = self.translated(content.text, known) - + def translated(self, value, type): """ translate using the schema type """ if value is not None: diff --git a/suds/wsdl.py b/txsuds/wsdl.py similarity index 98% rename from suds/wsdl.py rename to txsuds/wsdl.py index 5981c63..d56cec0 100644 --- a/suds/wsdl.py +++ b/txsuds/wsdl.py @@ -21,18 +21,17 @@ """ from logging import getLogger -from suds import * -from suds.sax import splitPrefix -from suds.sax.element import Element -from suds.bindings.document import Document -from suds.bindings.rpc import RPC, Encoded -from suds.xsd import qualify, Namespace -from suds.xsd.schema import Schema, SchemaCollection -from suds.xsd.query import ElementQuery -from suds.sudsobject import Object, Facade, Metadata -from suds.reader import DocumentReader, DefinitionsReader +from txsuds import * +from txsuds.sax.element import Element +from txsuds.bindings.document import Document +from txsuds.bindings.rpc import RPC, Encoded +from txsuds.xsd import qualify, Namespace +from txsuds.xsd.schema import Schema, SchemaCollection +from txsuds.xsd.query import ElementQuery +from txsuds.sudsobject import Object, Facade, Metadata +from txsuds.reader import DocumentReader from urlparse import urljoin -import re, soaparray +import re from twisted.internet import defer @@ -322,7 +321,7 @@ def load(self, definitions): url = urljoin(definitions.url, url) options = definitions.options d = Definitions(url, options) - yield d.open(url) + yield d.build() if d.root.match(Definitions.Tag, wsdlns): self.import_definitions(definitions, d) return diff --git a/suds/wsse.py b/txsuds/wsse.py similarity index 95% rename from suds/wsse.py rename to txsuds/wsse.py index 2a697c1..d7b7654 100644 --- a/suds/wsse.py +++ b/txsuds/wsse.py @@ -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, @@ -18,11 +18,10 @@ The I{wsse} module provides WS-Security. """ -from logging import getLogger -from suds import * -from suds.sudsobject import Object -from suds.sax.element import Element -from suds.sax.date import UTC +from txsuds import * +from txsuds.sudsobject import Object +from txsuds.sax.element import Element +from txsuds.sax.date import UTC from datetime import datetime, timedelta try: @@ -36,7 +35,7 @@ ('ds', 'http://www.w3.org/2000/09/xmldsig#') wssens = \ - ('wsse', + ('wsse', 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd') wsuns = \ ('wsu', @@ -58,7 +57,7 @@ class Security(Object): @ivar keys: A list of encryption keys. @type keys: TBD """ - + def __init__(self): """ """ Object.__init__(self) @@ -67,7 +66,7 @@ def __init__(self): self.signatures = [] self.references = [] self.keys = [] - + def xml(self): """ Get xml representation of the object. @@ -83,20 +82,20 @@ def xml(self): class Token(Object): """ I{Abstract} security token. """ - + @classmethod def now(cls): return datetime.now() - + @classmethod def utc(cls): return datetime.utcnow() - + @classmethod def sysdate(cls): utc = UTC() return str(utc) - + def __init__(self): Object.__init__(self) @@ -126,7 +125,7 @@ def __init__(self, username=None, password=None): self.password = password self.nonce = None self.created = None - + def setnonce(self, text=None): """ Set I{nonce} which is arbitraty set of bytes to prevent @@ -145,7 +144,7 @@ def setnonce(self, text=None): self.nonce = m.hexdigest() else: self.nonce = text - + def setcreated(self, dt=None): """ Set I{created}. @@ -157,8 +156,8 @@ def setcreated(self, dt=None): self.created = Token.utc() else: self.created = dt - - + + def xml(self): """ Get xml representation of the object. @@ -200,7 +199,7 @@ def __init__(self, validity=90): Token.__init__(self) self.created = Token.utc() self.expires = self.created + timedelta(seconds=validity) - + def xml(self): root = Element("Timestamp", ns=wsuns) created = Element('Created', ns=wsuns) diff --git a/suds/xsd/__init__.py b/txsuds/xsd/__init__.py similarity index 97% rename from suds/xsd/__init__.py rename to txsuds/xsd/__init__.py index 0917f3f..e29fd8c 100644 --- a/suds/xsd/__init__.py +++ b/txsuds/xsd/__init__.py @@ -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, @@ -23,8 +23,8 @@ """ from logging import getLogger -from suds import * -from suds.sax import Namespace, splitPrefix +from txsuds import * +from txsuds.sax import Namespace, splitPrefix log = getLogger(__name__) diff --git a/suds/xsd/deplist.py b/txsuds/xsd/deplist.py similarity index 97% rename from suds/xsd/deplist.py rename to txsuds/xsd/deplist.py index 14ae19c..39d63ba 100644 --- a/suds/xsd/deplist.py +++ b/txsuds/xsd/deplist.py @@ -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, @@ -19,7 +19,7 @@ """ from logging import getLogger -from suds import * +from txsuds import * log = getLogger(__name__) @@ -48,7 +48,7 @@ def __init__(self): self.stack = [] self.pushed = set() self.sorted = None - + def add(self, *items): """ Add items to be sorted. @@ -62,7 +62,7 @@ def add(self, *items): key = item[0] self.index[key] = item return self - + def sort(self): """ Sort the list based on dependancies. @@ -73,7 +73,7 @@ def sort(self): self.pushed = set() for item in self.unsorted: popped = [] - self.push(item) + self.push(item) while len(self.stack): try: top = self.top() @@ -90,7 +90,7 @@ def sort(self): self.sorted.append(p) self.unsorted = self.sorted return self.sorted - + def top(self): """ Get the item at the top of the stack. @@ -98,7 +98,7 @@ def top(self): @rtype: (item, iter) """ return self.stack[-1] - + def push(self, item): """ Push and item onto the sorting stack. @@ -112,7 +112,7 @@ def push(self, item): frame = (item, iter(item[1])) self.stack.append(frame) self.pushed.add(item) - + def pop(self): """ Pop the top item off the stack and append diff --git a/suds/xsd/doctor.py b/txsuds/xsd/doctor.py similarity index 95% rename from suds/xsd/doctor.py rename to txsuds/xsd/doctor.py index d7bbc14..cb4fc97 100644 --- a/suds/xsd/doctor.py +++ b/txsuds/xsd/doctor.py @@ -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, @@ -20,9 +20,9 @@ """ from logging import getLogger -from suds.sax import splitPrefix, Namespace -from suds.sax.element import Element -from suds.plugin import DocumentPlugin, DocumentContext +from txsuds.sax import Namespace +from txsuds.sax.element import Element +from txsuds.plugin import DocumentPlugin, DocumentContext log = getLogger(__name__) @@ -46,10 +46,10 @@ class Practice(Doctor): @ivar doctors: A list of doctors. @type doctors: list """ - + def __init__(self): self.doctors = [] - + def add(self, doctor): """ Add a doctor to the practice @@ -78,7 +78,7 @@ def __init__(self, *tns): """ self.tns = [] self.add(*tns) - + def add(self, *tns): """ Add I{targetNamesapces} to be added. @@ -102,7 +102,7 @@ def match(self, root, ns): matched = 1 itself = ( ns == tns ) return ( matched and not itself ) - + class Import: """ @@ -119,7 +119,7 @@ class Import: """ xsdns = Namespace.xsdns - + def __init__(self, ns, location=None): """ @param ns: An import namespace. @@ -130,7 +130,7 @@ def __init__(self, ns, location=None): self.ns = ns self.location = location self.filter = TnsFilter() - + def setfilter(self, filter): """ Set the filter. @@ -138,7 +138,7 @@ def setfilter(self, filter): @type filter: L{TnsFilter} """ self.filter = filter - + def apply(self, root): """ Apply the import (rule) to the specified schema. @@ -157,7 +157,7 @@ def apply(self, root): node.set('schemaLocation', self.location) log.debug('inserting: %s', node) root.insert(node) - + def add(self, root): """ Add an to the specified schema root. @@ -169,8 +169,8 @@ def add(self, root): if self.location is not None: node.set('schemaLocation', self.location) log.debug('%s inserted', node) - root.insert(node) - + root.insert(node) + def exists(self, root): """ Check to see if the already exists @@ -185,7 +185,7 @@ def exists(self, root): if self.ns == ns: return 1 return 0 - + class ImportDoctor(Doctor, DocumentPlugin): """ @@ -199,7 +199,7 @@ def __init__(self, *imports): """ self.imports = [] self.add(*imports) - + def add(self, *imports): """ Add a namesapce to be checked. @@ -207,7 +207,7 @@ def add(self, *imports): @type imports: [L{Import},..] """ self.imports += imports - + def examine(self, node): for imp in self.imports: imp.apply(node) @@ -223,4 +223,3 @@ def parsed(self, context): for child in node: context.document = child self.parsed(context) - \ No newline at end of file diff --git a/suds/xsd/query.py b/txsuds/xsd/query.py similarity index 94% rename from suds/xsd/query.py rename to txsuds/xsd/query.py index c88b220..675b072 100644 --- a/suds/xsd/query.py +++ b/txsuds/xsd/query.py @@ -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, @@ -19,10 +19,10 @@ """ from logging import getLogger -from suds import * -from suds.sudsobject import * -from suds.xsd import qualify, isqref -from suds.xsd.sxbuiltin import Factory +from txsuds import * +from txsuds.sudsobject import * +from txsuds.xsd import qualify, isqref +from txsuds.xsd.sxbuiltin import Factory log = getLogger(__name__) @@ -31,7 +31,7 @@ class Query(Object): """ Schema query base class. """ - + def __init__(self, ref=None): """ @param ref: The schema reference being queried. @@ -44,7 +44,7 @@ def __init__(self, ref=None): self.resolved = False if not isqref(self.ref): raise Exception('%s, must be qref' % tostr(self.ref)) - + def execute(self, schema): """ Execute this query using the specified schema. @@ -55,7 +55,7 @@ def execute(self, schema): @rtype: L{sxbase.SchemaObject} """ raise Exception, 'not-implemented by subclass' - + def filter(self, result): """ Filter the specified result based on query criteria. @@ -70,7 +70,7 @@ def filter(self, result): if reject: log.debug('result %s, rejected by\n%s', Repr(result), self) return reject - + def result(self, result): """ Query result post processing. @@ -93,7 +93,7 @@ class BlindQuery(Query): the specified schema. It may be used to find Elements and Types but will match on an Element first. This query will also find builtins. """ - + def execute(self, schema): if schema.builtin(self.ref): name = self.ref[0] @@ -119,7 +119,7 @@ class TypeQuery(Query): Schema query class that searches for Type references in the specified schema. Matches on root types only. """ - + def execute(self, schema): if schema.builtin(self.ref): name = self.ref[0] @@ -137,7 +137,7 @@ class GroupQuery(Query): Schema query class that searches for Group references in the specified schema. """ - + def execute(self, schema): result = schema.groups.get(self.ref) if self.filter(result): @@ -151,15 +151,15 @@ class AttrQuery(Query): the specified schema. Matches on root Attribute by qname first, then searches deep into the document. """ - + def execute(self, schema): result = schema.attributes.get(self.ref) if self.filter(result): result = self.__deepsearch(schema) return self.result(result) - + def __deepsearch(self, schema): - from suds.xsd.sxbasic import Attribute + from txsuds.xsd.sxbasic import Attribute result = None for e in schema.all: result = e.find(self.ref, (Attribute,)) @@ -175,7 +175,7 @@ class AttrGroupQuery(Query): Schema query class that searches for attributeGroup references in the specified schema. """ - + def execute(self, schema): result = schema.agrps.get(self.ref) if self.filter(result): @@ -189,15 +189,15 @@ class ElementQuery(Query): the specified schema. Matches on root Elements by qname first, then searches deep into the document. """ - + def execute(self, schema): result = schema.elements.get(self.ref) if self.filter(result): result = self.__deepsearch(schema) return self.result(result) - + def __deepsearch(self, schema): - from suds.xsd.sxbasic import Element + from txsuds.xsd.sxbasic import Element result = None for e in schema.all: result = e.find(self.ref, (Element,)) @@ -205,4 +205,4 @@ def __deepsearch(self, schema): result = None else: break - return result \ No newline at end of file + return result diff --git a/suds/xsd/schema.py b/txsuds/xsd/schema.py similarity index 97% rename from suds/xsd/schema.py rename to txsuds/xsd/schema.py index 221fc8b..398fe3d 100644 --- a/suds/xsd/schema.py +++ b/txsuds/xsd/schema.py @@ -23,21 +23,17 @@ """ -import suds.metrics -from suds import * -from suds.xsd import * -from suds.xsd.sxbuiltin import * -from suds.xsd.sxbasic import Factory as BasicFactory -from suds.xsd.sxbuiltin import Factory as BuiltinFactory -from suds.xsd.sxbase import SchemaObject -from suds.xsd.deplist import DepList -from suds.sax.element import Element -from suds.sax import splitPrefix, Namespace +from txsuds import * +from txsuds.xsd import * +from txsuds.xsd.sxbuiltin import * +from txsuds.xsd.sxbasic import Factory as BasicFactory +from txsuds.xsd.deplist import DepList +from txsuds.sax.element import Element +from txsuds.sax import splitPrefix, Namespace from logging import getLogger -from urlparse import urljoin - from twisted.internet import defer + log = getLogger(__name__) diff --git a/suds/xsd/sxbase.py b/txsuds/xsd/sxbase.py similarity index 96% rename from suds/xsd/sxbase.py rename to txsuds/xsd/sxbase.py index 2577ffd..641a759 100644 --- a/suds/xsd/sxbase.py +++ b/txsuds/xsd/sxbase.py @@ -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, @@ -20,10 +20,10 @@ """ from logging import getLogger -from suds import * -from suds.xsd import * -from suds.sax.element import Element -from suds.sax import Namespace +from txsuds import * +from txsuds.xsd import * +from txsuds.sax.element import Element +from txsuds.sax import Namespace log = getLogger(__name__) @@ -51,7 +51,7 @@ class SchemaObject(object): @classmethod def prepend(cls, d, s, filter=Filter()): """ - Prepend schema object's from B{s}ource list to + Prepend schema object's from B{s}ource list to the B{d}estination list while applying the filter. @param d: The destination list. @type d: list @@ -65,11 +65,11 @@ def prepend(cls, d, s, filter=Filter()): if x in filter: d.insert(i, x) i += 1 - + @classmethod def append(cls, d, s, filter=Filter()): """ - Append schema object's from B{s}ource list to + Append schema object's from B{s}ource list to the B{d}estination list while applying the filter. @param d: The destination list. @type d: list @@ -103,7 +103,7 @@ def __init__(self, schema, root): self.default = root.get('default') self.rawchildren = [] self.cache = {} - + def attributes(self, filter=Filter()): """ Get only the attribute content. @@ -117,7 +117,7 @@ def attributes(self, filter=Filter()): if child.isattr() and child in filter: result.append((child, ancestry)) return result - + def children(self, filter=Filter()): """ Get only the I{direct} or non-attribute content. @@ -131,7 +131,7 @@ def children(self, filter=Filter()): if not child.isattr() and child in filter: result.append((child, ancestry)) return result - + def get_attribute(self, name): """ Get (find) a I{non-attribute} attribute by name. @@ -144,7 +144,7 @@ def get_attribute(self, name): if child.name == name: return (child, ancestry) return (None, []) - + def get_child(self, name): """ Get (find) a I{non-attribute} child by name. @@ -170,10 +170,10 @@ def namespace(self, prefix=None): if ns[0] is None: ns = (prefix, ns[1]) return ns - + def default_namespace(self): return self.root.defaultNamespace() - + def unbounded(self): """ Get whether this node is unbounded I{(a collection)} @@ -187,7 +187,7 @@ def unbounded(self): return (int(max) > 1) else: return ( max == 'unbounded' ) - + def optional(self): """ Get whether this type is optional. @@ -198,7 +198,7 @@ def optional(self): if min is None: min = '1' return ( min == '0' ) - + def required(self): """ Get whether this type is required. @@ -206,8 +206,8 @@ def required(self): @rtype: boolean """ return ( not self.optional() ) - - + + def resolve(self, nobuiltin=False): """ Resolve and return the nodes true self. @@ -217,7 +217,7 @@ def resolve(self, nobuiltin=False): @rtype: L{SchemaObject} """ return self.cache.get(nobuiltin, self) - + def sequence(self): """ Get whether this is an @@ -225,7 +225,7 @@ def sequence(self): @rtype: boolean """ return False - + def xslist(self): """ Get whether this is an @@ -233,7 +233,7 @@ def xslist(self): @rtype: boolean """ return False - + def all(self): """ Get whether this is an @@ -241,7 +241,7 @@ def all(self): @rtype: boolean """ return False - + def choice(self): """ Get whether this is n @@ -249,7 +249,7 @@ def choice(self): @rtype: boolean """ return False - + def any(self): """ Get whether this is an @@ -257,7 +257,7 @@ def any(self): @rtype: boolean """ return False - + def builtin(self): """ Get whether this is a schema-instance (xs) type. @@ -265,7 +265,7 @@ def builtin(self): @rtype: boolean """ return False - + def enum(self): """ Get whether this is a simple-type containing an enumeration. @@ -273,7 +273,7 @@ def enum(self): @rtype: boolean """ return False - + def isattr(self): """ Get whether the object is a schema I{attribute} definition. @@ -281,7 +281,7 @@ def isattr(self): @rtype: boolean """ return False - + def extension(self): """ Get whether the object is an extension of another type. @@ -289,7 +289,7 @@ def extension(self): @rtype: boolean """ return False - + def restriction(self): """ Get whether the object is an restriction of another type. @@ -297,20 +297,20 @@ def restriction(self): @rtype: boolean """ return False - + def mixed(self): """ Get whether this I{mixed} content. """ return False - + def find(self, qref, classes=()): """ Find a referenced type in self or children. @param qref: A qualified reference. @type qref: qref @param classes: A list of classes used to qualify the match. - @type classes: [I{class},...] + @type classes: [I{class},...] @return: The referenced type. @rtype: L{SchemaObject} @see: L{qualify()} @@ -332,7 +332,7 @@ def translate(self, value, topython=True): @return: The converted I{language} type. """ return value - + def childtags(self): """ Get a list of valid child tag names. @@ -340,7 +340,7 @@ def childtags(self): @rtype: [str,...] """ return () - + def dependencies(self): """ Get a list of dependancies for dereferencing. @@ -348,7 +348,7 @@ def dependencies(self): @rtype: (int, [L{SchemaObject},...]) """ return (None, []) - + def autoqualified(self): """ The list of I{auto} qualified attribute values. @@ -357,7 +357,7 @@ def autoqualified(self): @rtype: list """ return ['type', 'ref'] - + def qualify(self): """ Convert attribute values, that are references to other @@ -378,7 +378,7 @@ def qualify(self): qref = qualify(ref, self.root, defns) log.debug('%s, convert %s="%s" to %s', self.id, a, ref, qref) setattr(self, a, qref) - + def merge(self, other): """ Merge another object as needed. @@ -398,8 +398,8 @@ def merge(self, other): if v is None: continue setattr(self, n, v) - - + + def content(self, collection=None, filter=Filter(), history=None): """ Get a I{flattened} list of this nodes contents. @@ -424,7 +424,7 @@ def content(self, collection=None, filter=Filter(), history=None): for c in self.rawchildren: c.content(collection, filter, history[:]) return collection - + def str(self, indent=0, history=None): """ Get a string representation of this object. @@ -433,7 +433,7 @@ def str(self, indent=0, history=None): @return: A string. @rtype: str """ - if history is None: + if history is None: history = [] if self in history: return '%s ...' % Repr(self) @@ -460,7 +460,7 @@ def str(self, indent=0, history=None): else: result.append(' />') return ''.join(result) - + def description(self): """ Get the names used for str() and repr() description. @@ -468,13 +468,13 @@ def description(self): @rtype: [str,...] """ return () - + def __str__(self): return unicode(self).encode('utf-8') - + def __unicode__(self): return unicode(self.str()) - + def __repr__(self): s = [] s.append('<%s' % self.id) @@ -488,15 +488,15 @@ def __repr__(self): s.append(' />') myrep = ''.join(s) return myrep.encode('utf-8') - + def __len__(self): n = 0 for x in self: n += 1 return n - + def __iter__(self): return Iter(self) - + def __getitem__(self, index): i = 0 for c in self: @@ -512,10 +512,10 @@ class Iter: @ivar stack: A stack used to control nesting. @type stack: list """ - + class Frame: """ A content iterator frame. """ - + def __init__(self, sx): """ @param sx: A schema object. @@ -524,7 +524,7 @@ def __init__(self, sx): self.sx = sx self.items = sx.rawchildren self.index = 0 - + def next(self): """ Get the I{next} item in the frame's collection. @@ -535,7 +535,7 @@ def next(self): result = self.items[self.index] self.index += 1 return result - + def __init__(self, sx): """ @param sx: A schema object. @@ -543,7 +543,7 @@ def __init__(self, sx): """ self.stack = [] self.push(sx) - + def push(self, sx): """ Create a frame and push the specified object. @@ -551,7 +551,7 @@ def push(self, sx): @type sx: L{SchemaObject} """ self.stack.append(Iter.Frame(sx)) - + def pop(self): """ Pop the I{top} frame. @@ -563,7 +563,7 @@ def pop(self): return self.stack.pop() else: raise StopIteration() - + def top(self): """ Get the I{top} frame. @@ -575,7 +575,7 @@ def top(self): return self.stack[-1] else: raise StopIteration() - + def next(self): """ Get the next item. @@ -594,7 +594,7 @@ def next(self): return (result, ancestry) self.push(result) return self.next() - + def __iter__(self): return self @@ -603,7 +603,7 @@ class XBuiltin(SchemaObject): """ Represents an (xsd) schema node """ - + def __init__(self, schema, name): """ @param schema: The containing schema. @@ -613,13 +613,13 @@ def __init__(self, schema, name): SchemaObject.__init__(self, schema, root) self.name = name self.nillable = True - + def namespace(self, prefix=None): return Namespace.xsdns - + def builtin(self): return True - + def resolve(self, nobuiltin=False): return self @@ -631,7 +631,7 @@ class Content(SchemaObject): """ pass - + class NodeFinder: """ Find nodes based on flexable criteria. The I{matcher} is @@ -650,7 +650,7 @@ def __init__(self, matcher, limit=0): """ self.matcher = matcher self.limit = limit - + def find(self, node, list): """ Traverse the tree looking for matches. diff --git a/suds/xsd/sxbasic.py b/txsuds/xsd/sxbasic.py similarity index 99% rename from suds/xsd/sxbasic.py rename to txsuds/xsd/sxbasic.py index e8135ae..dbaacff 100644 --- a/suds/xsd/sxbasic.py +++ b/txsuds/xsd/sxbasic.py @@ -20,13 +20,13 @@ """ from logging import getLogger -from suds import * -from suds.xsd import * -from suds.xsd.sxbase import * -from suds.xsd.query import * -from suds.sax import splitPrefix, Namespace -from suds.transport import TransportError -from suds.reader import DocumentReader +from txsuds import * +from txsuds.xsd import * +from txsuds.xsd.sxbase import * +from txsuds.xsd.query import * +from txsuds.sax import Namespace +from txsuds.transport import TransportError +from txsuds.reader import DocumentReader from urlparse import urljoin from twisted.internet import defer diff --git a/suds/xsd/sxbuiltin.py b/txsuds/xsd/sxbuiltin.py similarity index 98% rename from suds/xsd/sxbuiltin.py rename to txsuds/xsd/sxbuiltin.py index d013d8d..bbd4500 100644 --- a/suds/xsd/sxbuiltin.py +++ b/txsuds/xsd/sxbuiltin.py @@ -20,10 +20,10 @@ """ from logging import getLogger -from suds import * -from suds.xsd import * -from suds.sax.date import * -from suds.xsd.sxbase import XBuiltin +from txsuds import * +from txsuds.xsd import * +from txsuds.sax.date import * +from txsuds.xsd.sxbase import XBuiltin import datetime as dt