aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@230.to>2013-07-20 22:00:54 +0300
committerFilipp Lepalaan <f@230.to>2013-07-20 22:00:54 +0300
commit05551fbdd641d25cc20648afade7e8c78545a341 (patch)
treec641c878c9a09b73e2c0c378b6bcca39fec04c39
parentce8ada78e4b285f51ae83ad78990b16582588a36 (diff)
downloadpy-gsxws-05551fbdd641d25cc20648afade7e8c78545a341.tar.gz
py-gsxws-05551fbdd641d25cc20648afade7e8c78545a341.tar.bz2
py-gsxws-05551fbdd641d25cc20648afade7e8c78545a341.zip
Return prices correctly
-rw-r--r--gsxws/objectify.py8
-rw-r--r--tests/fixtures/parts_lookup.xml2
2 files changed, 4 insertions, 6 deletions
diff --git a/gsxws/objectify.py b/gsxws/objectify.py
index 43d6426..a1856d9 100644
--- a/gsxws/objectify.py
+++ b/gsxws/objectify.py
@@ -51,10 +51,8 @@ def gsx_boolean(value):
return value == 'Y' or value == 'true'
-class GsxPriceElement():
- @property
- def pyval(self):
- return float(re.sub(r'[A-Z ,]', '', self.text))
+def gsx_price(value):
+ return float(re.sub(r'[A-Z ,]', '', value))
def gsx_attachment(value):
@@ -97,7 +95,7 @@ class GsxElement(objectify.ObjectifiedElement):
if name in BASE64_TYPES:
return gsx_attachment(result)
if name in FLOAT_TYPES:
- return GsxPriceElement
+ return gsx_price(result)
if re.search(r'Date$', name):
return gsx_date(result)
if re.search(r'^[YN]$', result):
diff --git a/tests/fixtures/parts_lookup.xml b/tests/fixtures/parts_lookup.xml
index c1ffcb6..11f962d 100644
--- a/tests/fixtures/parts_lookup.xml
+++ b/tests/fixtures/parts_lookup.xml
@@ -12,7 +12,7 @@
<partDescription>SVC,REMOTE</partDescription>
<partNumber>661-4448</partNumber>
<partType>Module</partType>
- <stockPrice>17.1</stockPrice>
+ <stockPrice>EUR 17.1</stockPrice>
<stockPrice>17.1</stockPrice>
<componentCode>5</componentCode>
<originalPartNumber>661-2549</originalPartNumber>