Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into mvantellingen#1212
Browse files Browse the repository at this point in the history
  • Loading branch information
renatodamas committed Jun 16, 2022
2 parents 4eb6d5c + 2f35b7d commit e20aa1f
Show file tree
Hide file tree
Showing 32 changed files with 153 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 4.0.0
current_version = 4.1.0
commit = true
tag = true
tag_name = {new_version}
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
Expand All @@ -20,10 +20,14 @@ jobs:
test:
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
max-parallel: 4
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.6", "3.7", "3.8"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
# TODO: Remove Windows exclusion when binary wheel available for lxml
exclude:
- { platform: windows-latest, python-version: "3.10" }

steps:
- name: Install system dependencies
Expand All @@ -37,7 +41,7 @@ jobs:
brew install libxmlsec1 libxslt pkgconfig
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down Expand Up @@ -65,7 +69,7 @@ jobs:
name: coverage-data
path: .
- name: Set up Python 3.7
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
Expand Down
11 changes: 11 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
4.1.0 (2021-08-15)
------------------
- Remove last dependency on `six` (#1250)
- Use `platformdirs` instead of the `appsdirs` dependency (#1244)
- Pass digest method when signing timestamp node(#1201)
- Fix settings context manager when an exception is raised (#1193)
- Don't render decimals using scientific notation (#1191)
- Remove dependency on `defusedxml` (deprecated) (#1179)
- Improve handling of str values for Duration (#1165)


4.0.0 (2020-10-12)
------------------
- Drop support for Python 2.7, 3.3, 3.4 and 3.5
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016-2017 Michael van Tellingen
Copyright (c) 2016-2021 Michael van Tellingen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ include CHANGES
include CONTRIBUTORS.rst
include LICENSE
include README.rst
include pyproject.toml
include setup.cfg
include setup.py

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Zeep: Python SOAP client
A fast and modern Python SOAP client

Highlights:
* Compatible with Python 3.6, 3.7, 3.8 and PyPy
* Compatible with Python 3.6, 3.7, 3.8, 3.9, 3.10 and PyPy3
* Build on top of lxml and requests
* Support for Soap 1.1, Soap 1.2 and HTTP bindings
* Support for WS-Addressing headers
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
# built documents.
#
# The short X.Y version.
version = '4.0.0'
version = '4.1.0'
release = version

# The language for content autogenerated by Sphinx. Refer to documentation
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ See ``python -mzeep --help`` for more information about this command.

.. note:: Zeep follows `semver`_ for versioning, however bugs can always occur.
So as always pin the version of zeep you tested with
(e.g. ``zeep==4.0.0``').
(e.g. ``zeep==4.1.0``').


.. _semver: http://semver.org/
Expand Down
5 changes: 4 additions & 1 deletion docs/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ Writing a plugin is really simple and best explained via an example.
The plugin can implement two methods: ``ingress`` and ``egress``. Both methods
should always return an envelop (lxml element) and the http headers.
should always return an envelop (lxml element) and the http headers. The
envelope in the ``egress`` plugin will only contain the body of the soap message.
This is important to remember if you want to inspect or do something
with the headers.

To register this plugin you need to pass it to the client. Plugins are always
executed sequentially.
Expand Down
13 changes: 7 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from setuptools import setup

install_requires = [
"appdirs>=1.4.0",
"attrs>=17.2.0",
"cached-property>=1.3.0",
"cached-property>=1.3.0; python_version<'3.8'",
"isodate>=0.5.4",
"lxml>=4.6.0",
"platformdirs>=1.4.0",
"requests>=2.7.0",
"requests-toolbelt>=0.7.1",
"requests-file>=1.5.1",
Expand All @@ -27,12 +27,11 @@
tests_require = [
"coverage[toml]==5.2.1",
"freezegun==0.3.15",
"mock==2.0.0",
"pretend==1.0.9",
"pytest-cov==2.8.1",
"pytest-httpx",
"pytest-asyncio",
"pytest==6.0.1",
"pytest==6.2.5",
"requests_mock>=0.7.0",
# Linting
"isort==5.3.2",
Expand All @@ -50,12 +49,12 @@

setup(
name="zeep",
version="4.0.0",
version="4.1.0",
description="A modern/fast Python SOAP client based on lxml / requests",
long_description=long_description,
author="Michael van Tellingen",
author_email="[email protected]",
url="http://docs.python-zeep.org",
url="https://docs.python-zeep.org",
python_requires=">=3.6",
install_requires=install_requires,
tests_require=tests_require,
Expand All @@ -74,10 +73,12 @@
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
],
Expand Down
2 changes: 1 addition & 1 deletion src/zeep/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from zeep.transports import Transport # noqa
from zeep.xsd.valueobjects import AnyObject # noqa

__version__ = "4.0.0"
__version__ = "4.1.0"
4 changes: 2 additions & 2 deletions src/zeep/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import typing
from contextlib import contextmanager

import appdirs
import platformdirs
import pytz

# The sqlite3 is not available on Google App Engine so we handle the
Expand Down Expand Up @@ -176,7 +176,7 @@ def _is_expired(value, timeout):


def _get_default_cache_path():
path = appdirs.user_cache_dir("zeep", False)
path = platformdirs.user_cache_dir("zeep", False)
try:
os.makedirs(path)
except OSError as exc:
Expand Down
12 changes: 6 additions & 6 deletions src/zeep/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
import typing
from urllib.parse import urljoin, urlparse, urlunparse

from exceptions import DTDForbidden, EntitiesForbidden
from lxml import etree
from lxml.etree import fromstring, XMLParser, XMLSyntaxError, Resolver
from lxml.etree import Resolver, XMLParser, XMLSyntaxError, fromstring

from zeep.exceptions import XMLSyntaxError
from zeep.exceptions import DTDForbidden, EntitiesForbidden, XMLSyntaxError
from zeep.settings import Settings


Expand Down Expand Up @@ -48,19 +47,20 @@ def parse_xml(content: str, transport, base_url=None, settings=None):
)
parser.resolvers.add(ImportResolver(transport))
try:
elementtree = fromstring(content, parser=parser,base_url=base_url)
elementtree = fromstring(content, parser=parser, base_url=base_url)
docinfo = elementtree.getroottree().docinfo
if docinfo.doctype:
if settings.forbid_dtd:
raise DTDForbidden(docinfo.doctype, docinfo.system_url, docinfo.public_id)
raise DTDForbidden(
docinfo.doctype, docinfo.system_url, docinfo.public_id
)
if settings.forbid_entities:
for dtd in docinfo.internalDTD, docinfo.externalDTD:
if dtd is None:
continue
for entity in dtd.iterentities():
raise EntitiesForbidden(entity.name, entity.content)


return elementtree
except etree.XMLSyntaxError as exc:
raise XMLSyntaxError(
Expand Down
4 changes: 2 additions & 2 deletions src/zeep/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ def __getitem__(self, key):
raise AttributeError("Service has no operation %r" % key)

def __iter__(self):
""" Return iterator over the services and their callables. """
"""Return iterator over the services and their callables."""
return iter(self._operations.items())

def __dir__(self):
""" Return the names of the operations. """
"""Return the names of the operations."""
return list(itertools.chain(dir(super()), self._operations))


Expand Down
6 changes: 5 additions & 1 deletion src/zeep/transports.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, cache=None, timeout=300, operation_timeout=None, session=None
self.operation_timeout = operation_timeout
self.logger = logging.getLogger(__name__)

self.__close_session = not session
self.session = session or requests.Session()
self.session.mount("file://", FileAdapter())
self.session.headers["User-Agent"] = "Zeep/%s (www.python-zeep.org)" % (
Expand Down Expand Up @@ -154,6 +155,10 @@ def settings(self, timeout=None):
yield
self.operation_timeout = old_timeout

def __del__(self):
if self.__close_session:
self.session.close()


class AsyncTransport(Transport):
"""Asynchronous Transport class using httpx.
Expand All @@ -170,7 +175,6 @@ def __init__(
cache=None,
timeout=300,
operation_timeout=None,
session=None,
verify_ssl=True,
proxy=None,
):
Expand Down
6 changes: 5 additions & 1 deletion src/zeep/wsdl/attachments.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

import base64

from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property

from requests.structures import CaseInsensitiveDict


Expand Down
4 changes: 2 additions & 2 deletions src/zeep/wsdl/bindings/soap.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,15 @@ def process_error(self, doc, operation):
)

def get_text(name):
child = fault_node.find(name)
child = fault_node.find(name, namespaces=fault_node.nsmap)
if child is not None:
return child.text

raise Fault(
message=get_text("faultstring"),
code=get_text("faultcode"),
actor=get_text("faultactor"),
detail=fault_node.find("detail"),
detail=fault_node.find("detail", namespaces=fault_node.nsmap),
)

def _set_http_headers(self, serialized, operation):
Expand Down
2 changes: 1 addition & 1 deletion src/zeep/wsse/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def _signature_prepare(envelope, key, signature_method, digest_method):
_sign_node(ctx, signature, envelope.find(QName(soap_env, "Body")), digest_method)
timestamp = security.find(QName(ns.WSU, "Timestamp"))
if timestamp != None:
_sign_node(ctx, signature, timestamp)
_sign_node(ctx, signature, timestamp, digest_method)
ctx.sign(signature)

# Place the X509 data inside a WSSE SecurityTokenReference within
Expand Down
4 changes: 1 addition & 3 deletions src/zeep/wsse/username.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import hashlib
import os

import six

from zeep import ns
from zeep.wsse import utils

Expand Down Expand Up @@ -108,7 +106,7 @@ def _create_password_digest(self):
nonce = os.urandom(16)
timestamp = utils.get_timestamp(self.created, self.zulu_timestamp)

if isinstance(self.password, six.string_types):
if isinstance(self.password, str):
password = self.password.encode("utf-8")
else:
password = self.password
Expand Down
6 changes: 5 additions & 1 deletion src/zeep/xsd/elements/indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
import typing
from collections import OrderedDict, defaultdict, deque

from cached_property import threaded_cached_property
try:
from functools import cached_property as threaded_cached_property
except ImportError:
from cached_property import threaded_cached_property

from lxml import etree

from zeep.exceptions import UnexpectedElementError, ValidationError
Expand Down
6 changes: 5 additions & 1 deletion src/zeep/xsd/types/any.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import logging
import typing

from cached_property import threaded_cached_property
try:
from functools import cached_property as threaded_cached_property
except ImportError:
from cached_property import threaded_cached_property

from lxml import etree

from zeep.utils import qname_attr
Expand Down
4 changes: 3 additions & 1 deletion src/zeep/xsd/types/builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,12 @@ def pythonvalue(self, value):

class Duration(BuiltinType):
_default_qname = xsd_ns("duration")
accepted_types = [isodate.duration.Duration, str]
accepted_types = [isodate.duration.Duration, datetime.timedelta, str]

@check_no_collection
def xmlvalue(self, value):
if isinstance(value, str):
value = isodate.parse_duration(value)
return isodate.duration_isoformat(value)

@treat_whitespace("collapse")
Expand Down
6 changes: 5 additions & 1 deletion src/zeep/xsd/types/complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
from collections import OrderedDict, deque
from itertools import chain

from cached_property import threaded_cached_property
try:
from functools import cached_property as threaded_cached_property
except ImportError:
from cached_property import threaded_cached_property

from lxml import etree

from zeep.exceptions import UnexpectedElementError, XMLParseError
Expand Down
Loading

0 comments on commit e20aa1f

Please sign in to comment.