8000 Try the non-caching zeep client on older versions · AmarisAI/python-stdnum@7bb0e5f · GitHub
[go: up one dir, main page]

Skip to content

Commit 7bb0e5f

Browse files
committed
Try the non-caching zeep client on older versions
This uses the "normal" Client class from zeep if CachingClient is not available (this is the case on older zeep versions). This also records (and documents) the dependencies for SOAP libraries in setup.py.
1 parent 6d7ba46 commit 7bb0e5f

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

setup.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@
6868
packages=find_packages(),
6969
package_data={'': ['*.dat']},
7070
extras_require={
71-
'VIES': ['suds'],
72-
'VIES-ALT': ['PySimpleSOAP'],
71+
# The SOAP feature is only required for a number of online tests
72+
# of numbers such as the EU VAT VIES lookup, the Dominican Republic
73+
# DGII services or the Turkish T.C. Kimlik validation.
74+
'SOAP': ['zeep'], # recommended implementation
75+
'SOAP-ALT': ['suds'], # but this should also work
76+
'SOAP-FALLBACK': ['PySimpleSOAP'], # this is a fallback
7377
},
7478
)

stdnum/util.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,22 +178,28 @@ def get_soap_client(wsdlurl): # pragma: no cover (not part of normal test suite
178178
# this function isn't automatically tested because the functions using
179179
# it are not automatically tested
180180
if wsdlurl not in _soap_clients:
181-
try:
182-
from urllib import getproxies
183-
except ImportError:
184-
from urllib.request import getproxies
185181
# try zeep first
186182
try:
187183
from zeep import CachingClient
188184
client = CachingClient(wsdlurl).service
189185
except ImportError:
190-
# fall back to suds
186+
# fall back to non-caching zeep client
191187
try:
192-
from suds.client import Client
193-
client = Client(wsdlurl, proxy=getproxies()).service
188+
from zeep import Client
189+
client = Client(wsdlurl).service
194190
except ImportError:
195-
# use pysimplesoap as last resort
196-
from pysimplesoap.client import SoapClient
197-
client = SoapClient(wsdl=wsdlurl, proxy=getproxies())
191+
# other implementations require passing the proxy config
192+
try:
193+
from urllib import getproxies
194+
except ImportError:
195+
from urllib.request import getproxies
196+
# fall back to suds
197+
try:
198+
from suds.client import Client
199+
client = Client(wsdlurl, proxy=getproxies()).service
200+
except ImportError:
201+
# use pysimplesoap as last resort
202+
from pysimplesoap.client import SoapClient
203+
client = SoapClient(wsdl=wsdlurl, proxy=getproxies())
198204
_soap_clients[wsdlurl] = client
199205
return _soap_clients[wsdlurl]

0 commit comments

Comments
 (0)
0