aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@230.to>2013-09-09 08:45:52 +0300
committerFilipp Lepalaan <f@230.to>2013-09-09 08:45:52 +0300
commit8030271870fe174cb7f47677ef7cafa595d9ddc5 (patch)
tree29971f5ea9f39a299fae483e393b63264795d06a
parentf1e1789e1a9cdebf5268d0fa3dd2846178669777 (diff)
downloadpy-gsxws-8030271870fe174cb7f47677ef7cafa595d9ddc5.tar.gz
py-gsxws-8030271870fe174cb7f47677ef7cafa595d9ddc5.tar.bz2
py-gsxws-8030271870fe174cb7f47677ef7cafa595d9ddc5.zip
Minor tweaks
-rw-r--r--gsxws/objectify.py5
-rw-r--r--gsxws/products.py18
-rw-r--r--tests/fixtures/repair_details_ca.xml4
3 files changed, 20 insertions, 7 deletions
diff --git a/gsxws/objectify.py b/gsxws/objectify.py
index 5658d1a..007a523 100644
--- a/gsxws/objectify.py
+++ b/gsxws/objectify.py
@@ -76,15 +76,14 @@ def gsx_timestamp(value):
class GsxElement(objectify.ObjectifiedElement):
def __getattribute__(self, name):
-
try:
result = super(GsxElement, self).__getattribute__(name)
except AttributeError:
"""
The XML returned by GSX can be pretty inconsistent, especially
between the different environments. It's therefore more
- practical to return None than to look for AttributeErrors all
- over your application...
+ practical to return None than to expect AttributeErrors all
+ over your application.
"""
return
diff --git a/gsxws/products.py b/gsxws/products.py
index 1552ec2..fe31e7f 100644
--- a/gsxws/products.py
+++ b/gsxws/products.py
@@ -76,6 +76,9 @@ class Product(object):
self._gsx._submit("unitDetail", "WarrantyStatus", "warrantyDetailInfo")
self.warrantyDetails = self._gsx._req.objects
+ self.productDescription = self.warrantyDetails.productDescription
+ self.description = self.productDescription.lstrip('~VIN,')
+
return self.warrantyDetails
def parts(self):
@@ -143,8 +146,19 @@ class Product(object):
"""
Returns true if this iOS device is unlocked
"""
- import re
- return ad.unlocked or (re.search("Unlock", ad.nextTetherPolicyDetails) is not None)
+ return ad.unlocked or ("unlock" in ad.nextTetherPolicyDetails)
+
+ @property
+ def is_iphone(self):
+ return self.description.startswith('iPhone')
+
+ @property
+ def is_ipad(self):
+ return self.description.startswith('iPad')
+
+ @property
+ def is_ios(self):
+ return self.is_iphone or self.is_ipad
@property
def has_warranty(self):
diff --git a/tests/fixtures/repair_details_ca.xml b/tests/fixtures/repair_details_ca.xml
index c3a6a57..562bf7d 100644
--- a/tests/fixtures/repair_details_ca.xml
+++ b/tests/fixtures/repair_details_ca.xml
@@ -30,8 +30,8 @@
<county>Madera</county>
<region>005</region>
<city>CUPERTINO</city>
- <firstName>??kk?set</firstName>
- <lastName>T?ss?kin</lastName>
+ <firstName>Ääkköset</firstName>
+ <lastName>Tässäkin</lastName>
<primaryPhone>999999999</primaryPhone>
</primaryAddress>
<partsInfo>