aboutsummaryrefslogtreecommitdiffstats
path: root/gsxws.py
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@230.to>2013-05-05 23:09:24 +0300
committerFilipp Lepalaan <f@230.to>2013-05-05 23:09:24 +0300
commit0da7344a69d1c805835a67e2048b3026957aa30b (patch)
treeb9839afce7bcc216b05d9f03ae1452a6ea23a341 /gsxws.py
parent6add9f4ad804df36c8530811627186128db73728 (diff)
downloadpy-gsxws-0da7344a69d1c805835a67e2048b3026957aa30b.tar.gz
py-gsxws-0da7344a69d1c805835a67e2048b3026957aa30b.tar.bz2
py-gsxws-0da7344a69d1c805835a67e2048b3026957aa30b.zip
Misc tweaks
Diffstat (limited to 'gsxws.py')
-rwxr-xr-xgsxws.py35
1 files changed, 19 insertions, 16 deletions
diff --git a/gsxws.py b/gsxws.py
index ed1cd8d..48ec05a 100755
--- a/gsxws.py
+++ b/gsxws.py
@@ -203,7 +203,7 @@ class GsxObject(object):
# decode binary data
if k in ['packingList', 'proformaFileData', 'returnLabelFileData']:
v = base64.b64decode(v)
-
+
if isinstance(v, basestring):
# convert dates to native Python types
if re.search('^\d{2}/\d{2}/\d{2}$', v):
@@ -238,7 +238,7 @@ class GsxObject(object):
pass
rd = ReturnData()
-
+
for r in xml_el.iter():
k, v = r.tag, r.text
if k in ['packingList', 'proformaFileData', 'returnLabelFileData']:
@@ -251,24 +251,26 @@ class GsxObject(object):
def __getattr__(self, name):
return self.data[name]
+
class Content(GsxObject):
def fetch_image(self, url):
- '''
- The Fetch Image API allows users to get the image file from GSX,
- for the content articles, using the image URL.
- The image URLs will be obtained from the image html tags
- in the data from all content APIs.
- '''
+ """
+ The Fetch Image API allows users to get the image file from GSX,
+ for the content articles, using the image URL.
+ The image URLs will be obtained from the image html tags
+ in the data from all content APIs.
+ """
dt = self._make_type('ns3:fetchImageRequestType')
dt.imageRequest = {'imageUrl': url}
return self.submit('FetchImage', dt, 'contentResponse')
+
class CompTIA(object):
'''
Stores and accesses CompTIA codes.
'''
-
+
MODIFIERS = (
("A", "Not Applicable"),
("B", "Continuous"),
@@ -278,7 +280,7 @@ class CompTIA(object):
("F", "Configuration: Peripheral"),
("G", "Damaged"),
)
-
+
GROUPS = (
('0', 'General'),
('1', 'Visual'),
@@ -295,14 +297,14 @@ class CompTIA(object):
('E', 'iPod'),
('F', 'iPad'),
)
-
+
def __init__(self):
"""
Initialize CompTIA symptoms from JSON file
"""
df = open(os.path.join(os.path.dirname(__file__), 'comptia.json'))
self.data = json.load(df)
-
+
def fetch(self):
"""
The CompTIA Codes Lookup API retrieves a list of CompTIA groups and modifiers.
@@ -335,7 +337,7 @@ class CompTIA(object):
for ci in el.findall('comptiaCodeInfo'):
group[ci[0].text] = ci[1].text
-
+
self.data[comp_id] = group
COMPTIA_CACHE.put("comptia", self.data)
@@ -347,14 +349,15 @@ class CompTIA(object):
belonging to the given component code.
"""
r = dict()
-
+
for g, codes in self.data.items():
r[g] = list()
for k, v in codes.items():
r[g].append((k, v,))
-
+
return r[component] if component else r
+
class GsxResponse(dict):
"""
This contains the data returned by a raw GSX query
@@ -368,7 +371,7 @@ class GsxResponse(dict):
@classmethod
def Process(cls, node):
nodedict = cls()
-
+
for child in node:
k, v = child.tag, child.text
newitem = cls.Process(child)