lists.arthurdejong.org
RSS feed

python-stdnum branch master updated. 1.1-3-ga1a134e

[Date Prev][Date Next] [Thread Prev][Thread Next]

python-stdnum branch master updated. 1.1-3-ga1a134e



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-stdnum".

The branch, master has been updated
       via  a1a134e91b0ca3ccdff69929c4555c62e10c8714 (commit)
      from  8fe44f98a0d8709912ddf7fc383c14d72472d819 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://arthurdejong.org/git/python-stdnum/commit/?id=a1a134e91b0ca3ccdff69929c4555c62e10c8714

commit a1a134e91b0ca3ccdff69929c4555c62e10c8714
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Sun Jul 12 13:14:22 2015 +0200

    Fall back to pysimplesoap if suds is unavailable
    
    Initial testing seems to suggest that proxy-support is not complete with
    pysimplesoap (at least httplib2 and PySocks seem to be required).

diff --git a/stdnum/eu/vat.py b/stdnum/eu/vat.py
index a0ff0b9..d867e3b 100644
--- a/stdnum/eu/vat.py
+++ b/stdnum/eu/vat.py
@@ -121,12 +121,18 @@ def _get_client():  # pragma: no cover (no tests for this 
function)
     # it are not automatically tested
     global _vies_client
     if not _vies_client:
-        from suds.client import Client
         try:
             from urllib import getproxies
         except ImportError:
             from urllib.request import getproxies
-        _vies_client = Client(vies_wsdl, proxy=getproxies())
+        # try suds first
+        try:
+            from suds.client import Client
+            _vies_client = Client(vies_wsdl, proxy=getproxies()).service
+        except ImportError:
+            # fall back to using pysimplesoap
+            from pysimplesoap.client import SoapClient
+            _vies_client = SoapClient(wsdl=vies_wsdl, proxy=getproxies())
     return _vies_client
 
 
@@ -138,7 +144,7 @@ def check_vies(number):  # pragma: no cover (no tests for 
this function)
     # this function isn't automatically tested because it would require
     # network access for the tests and unnecessarily load the VIES website
     number = compact(number)
-    return _get_client().service.checkVat(number[:2], number[2:])
+    return _get_client().checkVat(number[:2], number[2:])
 
 
 def check_vies_approx(number, requester):  # pragma: no cover
@@ -151,6 +157,6 @@ def check_vies_approx(number, requester):  # pragma: no 
cover
     # network access for the tests and unnecessarily load the VIES website
     number = compact(number)
     requester = compact(requester)
-    return _get_client.service.checkVatApprox(
+    return _get_client.checkVatApprox(
         countryCode=number[:2], vatNumber=number[2:],
         requesterCountryCode=requester[:2], requesterVatNumber=requester[2:])

-----------------------------------------------------------------------

Summary of changes:
 stdnum/eu/vat.py |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
python-stdnum
-- 
To unsubscribe send an email to
python-stdnum-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/python-stdnum-commits/