Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

cleaned up position and education parsers

  • Loading branch information...
commit 01023ebf6d214eb89a7d7225fc769b1db53e368d 1 parent b8b99cf
Aaron Brenzel authored May 21, 2010

Showing 1 changed file with 10 additions and 70 deletions. Show diff stats Hide diff stats

  1. 80  liclient/parsers/lixml.py
80  liclient/parsers/lixml.py
@@ -242,41 +242,11 @@ def __init__(self, content):
242 242
     
243 243
     def __build_data(self, tree):
244 244
         data = {}
245  
-        try:
246  
-            data['id'] = self.xpath_collection['id'](tree)[0].text.strip() \
247  
-                if len(self.xpath_collection['id'](tree)) else None
248  
-        except:
249  
-            data['id'] = None
250  
-        try:
251  
-            data['title'] = self.xpath_collection['title'](tree)[0].text.strip() \
252  
-                if len(self.xpath_collection['title'](tree)) else None
253  
-        except:
254  
-            data['title'] = None
255  
-        try:
256  
-            data['summary'] = self.xpath_collection['summary'](tree)[0].text.strip() \
257  
-                if len(self.xpath_collection['summary'](tree)) else None
258  
-        except:
259  
-            data['summary'] = None
260  
-        try:
261  
-            data['start_date'] = self.xpath_collection['start-date'](tree)[0].text.strip() \
262  
-                if len(self.xpath_collection['start-date'](tree)) else None
263  
-        except:
264  
-            data['start_date'] = None
265  
-        try:
266  
-            data['end_date'] = self.xpath_collection['end-date'](tree)[0].text.strip() \
267  
-                if len(self.xpath_collection['end-date'](tree)) else None
268  
-        except:
269  
-            data['end_date'] = None
270  
-        try:
271  
-            data['is_current'] = self.xpath_collection['is-current'](tree)[0].text.strip() \
272  
-                if len(self.xpath_collection['is-current'](tree)) else None
273  
-        except:
274  
-            data['is_current'] = None
275  
-        try:
276  
-            data['company'] = self.xpath_collection['company'](tree)[0].text.strip() \
277  
-                if len(self.xpath_collection['company'](tree)) else None
278  
-        except:
279  
-            data['company'] = None
  245
+        for n in tree.getchildren():
  246
+            if not n.getchildren():
  247
+                data[re.sub('-', '_', n.tag)] = n.text
  248
+            else:
  249
+                data[re.sub('-', '_', n.getchildren()[0].tag)] = n.getchildren()[0].text
280 250
         results = mappers.Position(data, tree)
281 251
         return results
282 252
 
@@ -296,40 +266,10 @@ def __init__(self, content):
296 266
     
297 267
     def __build_data(self, tree):
298 268
         data = {}
299  
-        try:
300  
-            data['id'] = self.xpath_collection['id'](tree)[0].text.strip() \
301  
-                        if len(self.xpath_collection['id'](tree)) else None
302  
-        except:
303  
-            data['id'] = None
304  
-        try:
305  
-            data['school_name'] = self.xpath_collection['school-name'](tree)[0].text.strip() \
306  
-                        if len(self.xpath_collection['id'](tree)) else None
307  
-        except:
308  
-            data['school_name'] = None
309  
-        try:
310  
-            data['field_of_study'] = self.xpath_collection['field-of-study'](tree)[0].text.strip() \
311  
-                        if len(self.xpath_collection['id'](tree)) else None
312  
-        except:
313  
-            data['field_of_study'] = None
314  
-        try:
315  
-            data['start_date'] = self.xpath_collection['start-date'](tree)[0].text.strip() \
316  
-                        if len(self.xpath_collection['id'](tree)) else None
317  
-        except:
318  
-            data['start_date'] = None
319  
-        try:
320  
-            data['end_date'] = self.xpath_collection['end-date'](tree)[0].text.strip() \
321  
-                        if len(self.xpath_collection['id'](tree)) else None
322  
-        except:
323  
-            data['end_date'] = None
324  
-        try:
325  
-            data['degree'] = self.xpath_collection['degree'](tree)[0].text.strip() \
326  
-                        if len(self.xpath_collection['id'](tree)) else None
327  
-        except:
328  
-            data['degree'] = None
329  
-        try:
330  
-            data['activities'] = self.xpath_collection['activities'](tree)[0].text.strip() \
331  
-                        if len(self.xpath_collection['id'](tree)) else None
332  
-        except:
333  
-            data['activities'] = None
  269
+        for n in tree.getchildren():
  270
+            if not n.getchildren():
  271
+                data[re.sub('-', '_', n.tag)] = n.text
  272
+            else:
  273
+                data[re.sub('-', '_', n.getchildren()[0].tag)] = n.getchildren()[0].text
334 274
         results = mappers.Education(data, tree)
335 275
         return results

0 notes on commit 01023eb

Please sign in to comment.
Something went wrong with that request. Please try again.