aboutsummaryrefslogtreecommitdiffstats
path: root/gsxws.py
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@0x00.co>2013-03-28 18:49:36 +0200
committerFilipp Lepalaan <f@0x00.co>2013-03-28 18:49:36 +0200
commit013e6ce6ff126e892e5af824aa1c3c3ab268a11d (patch)
tree6ef592ecc9fe56ccc47f33c8a62d228bf2cf6c78 /gsxws.py
parent40cfeb5322012da8476a6047b78e233af5d29ec7 (diff)
downloadpy-gsxws-013e6ce6ff126e892e5af824aa1c3c3ab268a11d.tar.gz
py-gsxws-013e6ce6ff126e892e5af824aa1c3c3ab268a11d.tar.bz2
py-gsxws-013e6ce6ff126e892e5af824aa1c3c3ab268a11d.zip
Fixing CompTIA.fetch()
Diffstat (limited to 'gsxws.py')
-rwxr-xr-xgsxws.py34
1 files changed, 10 insertions, 24 deletions
diff --git a/gsxws.py b/gsxws.py
index a913ebe..7eb6ecc 100755
--- a/gsxws.py
+++ b/gsxws.py
@@ -212,43 +212,29 @@ class CompTIA:
def __init__(self):
df = open(os.path.join(os.path.dirname(__file__), 'comptia.json'))
self.data = json.load(df)
+ self.groups = dict()
+ self.modifiers = dict()
def fetch(self):
- """
+ '''
Here we must resort to raw XML parsing since SUDS throws this:
suds.TypeNotFound: Type not found: 'comptiaDescription'
when calling CompTIACodes()...
- """
+ '''
CLIENT.set_options(retxml=True)
dt = CLIENT.factory.create('ns3:comptiaCodeLookupRequestType')
dt.userSession = SESSION
xml = CLIENT.service.CompTIACodes(dt)
-
root = ET.fromstring(xml).findall('.//%s' % 'comptiaInfo')[0]
-
- # Process CompTIA Groups
- class ComptiaGroup:
- pass
-
- class ComptiaModifier:
- pass
-
- self.groups = list()
- self.modifiers = list()
-
+
for el in root.findall('.//comptiaGroup'):
- dt = ComptiaGroup()
+ for i in element.iter():
+ setattr(obj, i.tag, i.text)
self.groups.append(self.__process(el, dt))
-
+
for el in root.findall('.//comptiaModifier'):
- mod = ComptiaModifier()
- self.modifiers.append(self.__process(el, mod))
-
- def __process(self, element, obj):
- for i in element.iter():
- setattr(obj, i.tag, i.text)
-
- return obj
+ descr, code = list(el)
+ self.modifiers[code.text] = descr.text
def symptoms(self, component=None):
symptoms = self.data['symptoms']