aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@230.to>2013-03-30 19:25:09 +0200
committerFilipp Lepalaan <f@230.to>2013-03-30 19:25:09 +0200
commit0a590e684c8ba56ea24c439cef096ea83090172d (patch)
tree5443ab1f550a438bba60d3250ff71057c1276d79
parent65fabcbfc650e3c36108fce286edb4105a742f55 (diff)
downloadpy-gsxws-0a590e684c8ba56ea24c439cef096ea83090172d.tar.gz
py-gsxws-0a590e684c8ba56ea24c439cef096ea83090172d.tar.bz2
py-gsxws-0a590e684c8ba56ea24c439cef096ea83090172d.zip
Some fixes
-rwxr-xr-xgsxws.py30
1 files changed, 23 insertions, 7 deletions
diff --git a/gsxws.py b/gsxws.py
index 1076ee1..dd04a63 100755
--- a/gsxws.py
+++ b/gsxws.py
@@ -205,7 +205,7 @@ class GsxObject(object):
return rd
-class CompTIA:
+class CompTIA(object):
'''
Stores and accesses CompTIA codes.
'''
@@ -233,14 +233,16 @@ class CompTIA:
root = ET.fromstring(xml).findall('.//%s' % 'comptiaInfo')[0]
for el in root.findall('.//comptiaGroup'):
+ group = {}
comp_id = el[0].text
+ # @TODO - it would be nice to put the name of the group
+ # somewhere...
#group = {'id': comp_id, 'name': el[1].text}
#group['codes'] = dict()
- group = {}
+
for ci in el.findall('comptiaCodeInfo'):
group[ci[0].text] = ci[1].text
- # @TODO
self.data['symptoms'][comp_id] = group
for el in root.findall('.//comptiaModifier'):
@@ -250,16 +252,30 @@ class CompTIA:
return self.data['symptoms']
def symptoms(self, component=None):
+ '''
+ Returns all known CompTIA symptom codes or just the ones
+ belonging to the given component code.
+ '''
+ group = {}
symptoms = self.data['symptoms']
if component is None:
return symptoms
-
+
+ '''
+ Bundle the requested symptom codes as a Django-friendly
+ list of two-tuples.
+ '''
r = list()
-
- for k, v in symptoms[component].items():
+
+ try:
+ group = symptoms[component]
+ except Exception:
+ raise ValueError('Unknown component: %s' % component)
+
+ for k, v in group.items():
r.append((k, v))
-
+
return r
def modifiers(self):