Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2018-02-19 21:42:17 +0100
committerArthur de Jong <arthur@arthurdejong.org>2018-02-19 23:03:58 +0100
commit92d751cd03ff165f942ee9034399bb942262ad7f (patch)
tree4b962a893a96ef7b2c7752acaf674062bd1a709e
parent81947a26fffab3075b51a15f63844b9f89ef318e (diff)
Fix PySimpleSOAP DGII result parsing issue
This strips the wrapper that PySimpleSOAP puts around results from the DGII PySimpleSOAP SOAP call. Closes https://github.com/arthurdejong/python-stdnum/issues/64 Closes https://github.com/arthurdejong/python-stdnum/issues/65
-rw-r--r--stdnum/do/ncf.py2
-rw-r--r--stdnum/do/rnc.py10
2 files changed, 9 insertions, 3 deletions
diff --git a/stdnum/do/ncf.py b/stdnum/do/ncf.py
index c59d8b9..51b360d 100644
--- a/stdnum/do/ncf.py
+++ b/stdnum/do/ncf.py
@@ -128,6 +128,8 @@ def check_dgii(rnc, ncf, timeout=30): # pragma: no cover
RNC=rnc,
NCF=ncf,
IMEI='')
+ if result and 'GetNCFResult' in result:
+ result = result['GetNCFResult'] # PySimpleSOAP only
if result == '0':
return
return _convert_result(result)
diff --git a/stdnum/do/rnc.py b/stdnum/do/rnc.py
index ef6f30a..d1818a0 100644
--- a/stdnum/do/rnc.py
+++ b/stdnum/do/rnc.py
@@ -133,17 +133,19 @@ def check_dgii(number, timeout=30): # pragma: no cover
'payment_regime': '2', # 1: N/D, 2: NORMAL, 3: PST
}
- Will return none if the number is invalid or unknown."""
+ Will return None if the number is invalid or unknown."""
# this function isn't automatically tested because it would require
# network access for the tests and unnecessarily load the online service
number = compact(number)
client = get_soap_client(dgii_wsdl, timeout)
- result = '%s' % client.GetContribuyentes(
+ result = client.GetContribuyentes(
value=number,
patronBusqueda=0, # search type: 0=by number, 1=by name
inicioFilas=1, # start result (1-based)
filaFilas=1, # end result
IMEI='')
+ if result and 'GetContribuyentesResult' in result:
+ result = result['GetContribuyentesResult'] # PySimpleSOAP only
if result == '0':
return
return _convert_result(result)
@@ -178,12 +180,14 @@ def search_dgii(keyword, end_at=10, start_at=1, timeout=30): # pragma: no cover
# this function isn't automatically tested because it would require
# network access for the tests and unnecessarily load the online service
client = get_soap_client(dgii_wsdl, timeout)
- results = '%s' % client.GetContribuyentes(
+ results = client.GetContribuyentes(
value=keyword,
patronBusqueda=1, # search type: 0=by number, 1=by name
inicioFilas=start_at, # start result (1-based)
filaFilas=end_at, # end result
IMEI='')
+ if results and 'GetContribuyentesResult' in results:
+ results = results['GetContribuyentesResult'] # PySimpleSOAP only
if results == '0':
return []
return [_convert_result(result) for result in results.split('@@@')]