Skip to content

Commit

Permalink
Merge branch 'release/0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
tysonclugg committed Sep 10, 2015
2 parents b9e9727 + a2be85e commit 723995e
Show file tree
Hide file tree
Showing 10 changed files with 159 additions and 81 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changelog
=========

0.4.0
-----
* Use ``@cached_property`` to simplify property code.
* Fix ``AttributeError`` when debugging.
* Include missing XSD files in wheel distributions.
* Ensure XSD files exist in distributed files via tox test suite
options.

0.3.0
-----
* Add 'SOAPAction' header to requests.
Expand Down Expand Up @@ -51,4 +59,4 @@ Changelog

0.0.1
-----
* Generate SOAP requests and parse SOAP 1.1 responses.
* Generate SOAP requests and parse SOAP 1.1 responses.
14 changes: 7 additions & 7 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
include LICENSE
include Makefile
include *.rst
include docs/*.rst
include docs/conf.py
include docs/make.bat
include docs/Makefile
include docs/_static/*
include docs/_templates/*
include *.sh
include *.txt
include Makefile
recursive-include docs *.bat
recursive-include docs *.py
recursive-include docs *.rst
recursive-include docs Makefile
recursive-include rinse *.xsd
69 changes: 35 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
SOURCES := \
rinse/__init__.py \
rinse/client.py \
rinse/message.py \
rinse/response.py \
rinse/util.py \
rinse/wsa.py \
rinse/wsdl.py \
rinse/wsse.py \
rinse/xsd.py

DOCS := \
README.rst \
docs/index.rst \
docs/rinse.rst \
docs/rinse.client.rst \
docs/rinse.message.rst \
docs/rinse.response.rst \
docs/rinse.util.rst \
docs/rinse.wsa.rst \
docs/rinse.wsdl.rst \
docs/rinse.wsse.rst \
docs/rinse.xsd.rst

.PHONY: all test clean clean-docs

all: docs
NAME := $(shell python setup.py --name)
VERSION := $(shell python setup.py --version)

SDIST := dist/${NAME}-${VERSION}.tar.gz
WHEEL := dist/${NAME}-${VERSION}-py2.py3-none-any.whl

.PHONY: all test clean clean-docs upload-docs upload-pypi dist docs

all: docs dist

test:
python setup.py test
tox

clean: clean-docs
clean: clean-docs clean-sdist clean-wheel

clean-docs:
rm -rf docs/_build/
$(MAKE) -C docs/ clean

clean-sdist:
rm -f "${SDIST}"

clean-wheel:
rm -f "${WHEEL}"

docs:
$(MAKE) -C docs/ clean html

${SDIST}:
python setup.py sdist

${WHEEL}:
python setup.py bdist_wheel

dist: test ${SDIST} ${WHEEL}

upload: upload-pypi upload-docs

docs: docs/_build/
upload-pypi: ${SDIST} ${WHEEL}
twine upload "${WHEEL}" "${SDIST}"

docs/_build/: ${DOCS} ${SOURCES} docs/conf.py setup.py
rm -rf docs/_build/
cd docs && $(MAKE) html doctest
upload-docs: docs/_build/
python setup.py upload_sphinx --upload-dir="$<html"
15 changes: 3 additions & 12 deletions rinse/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
from __future__ import print_function
import requests
from rinse import ENVELOPE_XSD
from rinse.util import SCHEMA
from rinse.util import SCHEMA, cached_property
from rinse.response import RinseResponse


class SoapClient(object):

"""Rinse SOAP client."""

__session = None

def __init__(self, url, debug=False, **kwargs):
"""Set base attributes."""
self.url = url
Expand All @@ -20,17 +18,10 @@ def __init__(self, url, debug=False, **kwargs):
self.operations = {}
self.soap_schema = SCHEMA[ENVELOPE_XSD]

@property
@cached_property
def _session(self):
"""Cached instance of requests.Session."""
if self.__session is None:
self.__session = requests.Session()
return self.__session

@_session.setter
def _session(self, session):
"""Allow injecting your own instance of requests.Session."""
self.__session = session
return requests.Session()

def __call__(self, msg, action="", build_response=RinseResponse,
debug=False):
Expand Down
12 changes: 12 additions & 0 deletions rinse/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,15 @@ def recursive_dict(element):
map(recursive_dict, element)
) or element.text
)


class cached_property(object):
def __init__(self, func):
self.func = func
self.__doc__ = getattr(func, '__doc__')

def __get__(self, instance, owner):
if instance is None:
return self
result = instance.__dict__[self.func.__name__] = self.func(instance)
return result
24 changes: 11 additions & 13 deletions rinse/wsdl.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Rinse SOAP library: module providing WSDL functions."""
from lxml import etree
from rinse.util import safe_parse_path, safe_parse_url, element_as_tree
from rinse.util import (
safe_parse_path, safe_parse_url, element_as_tree, cached_property,
)
from rinse.xsd import XSDValidator, NS_XSD

NS_WSDL = 'http://schemas.xmlsoap.org/wsdl/'
Expand Down Expand Up @@ -31,22 +33,18 @@ def __init__(self, wsdl_root):
"""WSDL init."""
self.root = wsdl_root

@property
@cached_property
def schema(self):
"""Return schema element (used for XSD validation)."""
if self._schema is None:
schema_el = self.root.xpath(
'/wsdl:definitions/wsdl:types/xsd:schema', namespaces=NS_MAP,
)[0]
self._schema = element_as_tree(schema_el)
return self._schema

@property
schema_el = self.root.xpath(
'/wsdl:definitions/wsdl:types/xsd:schema', namespaces=NS_MAP,
)[0]
return element_as_tree(schema_el)

@cached_property
def xsd_validator(self):
"""Extract XML Schema Definition (XSD) element tree."""
if self._xsd_validator is None:
self._xsd_validator = XSDValidator(self.schema)
return self._xsd_validator
return XSDValidator(self.schema)

def is_valid(self, soapmsg):
"""Return True if SOAP message body validates against WSDL schema."""
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[bdist_wheel]
universal=1
50 changes: 36 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,48 @@
#!/usr/bin/env python
from setuptools import setup
from setuptools import setup, find_packages

CLASSIFIERS = [
# Beta status until 1.0 is released
"Development Status :: 4 - Beta",

# Who and what the project is for
"Intended Audience :: Developers",
"Topic :: Communications",
"Topic :: Internet",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Software Development :: Libraries",
"Topic :: Text Processing :: Markup :: XML",

# License classifiers
"License :: OSI Approved :: MIT License",
"License :: DFSG approved",
"License :: OSI Approved",

# Generally, we support the following.
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Framework :: Django",

# Specifically, we support the following releases.
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Framework :: Django :: 1.7",
"Framework :: Django :: 1.8",
]

setup(
name='rinse',
version='0.3.0',
version='0.4.0',
description='SOAP client built with lxml and requests.',
long_description=open('README.rst').read(),
author='Tyson Clugg',
author_email='tyson@clugg.net',
url='https://rinse.readthedocs.org/en/latest/',
license='MIT',
packages=['rinse'],
packages=find_packages(),
include_package_data=True,
zip_safe=False,
test_suite='rinse.tests',
Expand All @@ -20,15 +52,5 @@
'requests',
],
tests_require=['mock', 'six'],
classifiers=[
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"License :: OSI Approved :: MIT License",
"Topic :: Communications",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Software Development :: Libraries",
"Topic :: Text Processing :: Markup :: XML",
],
classifiers=CLASSIFIERS,
)
2 changes: 2 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-r requirements.txt
mock
42 changes: 42 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.

[tox]
# require tox>=2.1.1 or refuse to run the tests.
minversion=2.1.1

# return success even if some of the specified environments are missing
skip_missing_interpreters=True

# "envlist" is a comma separated list of environments, each environment name
# contains factors separated by hyphens. For example, "py27-unittest" has 2
# factors: "py27" and "unittest". Other settings such as "setenv" accept the
# factor names as a prefixes (eg: "unittest: ...") so that prefixed settings
# only apply if the environment being run contains that factor.

envlist =
py27-test,
py33-test,
py34-test,
py35-test,

[testenv]
recreate=True
usedevelop=False
passenv=
BUILD_NUMBER
BUILD_URL
XDG_CACHE_HOME

# continue running commands even if previous commands have failed
ignore_errors = True

commands =
coverage run --source={toxinidir}/rinse {toxinidir}/setup.py test
coverage report

deps =
-r{toxinidir}/test-requirements.txt
coverage

0 comments on commit 723995e

Please sign in to comment.