Skip to content

Commit

Permalink
cleaned up position and education parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron committed May 21, 2010
1 parent b8b99cf commit 01023eb
Showing 1 changed file with 10 additions and 70 deletions.
80 changes: 10 additions & 70 deletions liclient/parsers/lixml.py
Expand Up @@ -242,41 +242,11 @@ def __init__(self, content):


def __build_data(self, tree): def __build_data(self, tree):
data = {} data = {}
try: for n in tree.getchildren():
data['id'] = self.xpath_collection['id'](tree)[0].text.strip() \ if not n.getchildren():
if len(self.xpath_collection['id'](tree)) else None data[re.sub('-', '_', n.tag)] = n.text
except: else:
data['id'] = None data[re.sub('-', '_', n.getchildren()[0].tag)] = n.getchildren()[0].text
try:
data['title'] = self.xpath_collection['title'](tree)[0].text.strip() \
if len(self.xpath_collection['title'](tree)) else None
except:
data['title'] = None
try:
data['summary'] = self.xpath_collection['summary'](tree)[0].text.strip() \
if len(self.xpath_collection['summary'](tree)) else None
except:
data['summary'] = None
try:
data['start_date'] = self.xpath_collection['start-date'](tree)[0].text.strip() \
if len(self.xpath_collection['start-date'](tree)) else None
except:
data['start_date'] = None
try:
data['end_date'] = self.xpath_collection['end-date'](tree)[0].text.strip() \
if len(self.xpath_collection['end-date'](tree)) else None
except:
data['end_date'] = None
try:
data['is_current'] = self.xpath_collection['is-current'](tree)[0].text.strip() \
if len(self.xpath_collection['is-current'](tree)) else None
except:
data['is_current'] = None
try:
data['company'] = self.xpath_collection['company'](tree)[0].text.strip() \
if len(self.xpath_collection['company'](tree)) else None
except:
data['company'] = None
results = mappers.Position(data, tree) results = mappers.Position(data, tree)
return results return results


Expand All @@ -296,40 +266,10 @@ def __init__(self, content):


def __build_data(self, tree): def __build_data(self, tree):
data = {} data = {}
try: for n in tree.getchildren():
data['id'] = self.xpath_collection['id'](tree)[0].text.strip() \ if not n.getchildren():
if len(self.xpath_collection['id'](tree)) else None data[re.sub('-', '_', n.tag)] = n.text
except: else:
data['id'] = None data[re.sub('-', '_', n.getchildren()[0].tag)] = n.getchildren()[0].text
try:
data['school_name'] = self.xpath_collection['school-name'](tree)[0].text.strip() \
if len(self.xpath_collection['id'](tree)) else None
except:
data['school_name'] = None
try:
data['field_of_study'] = self.xpath_collection['field-of-study'](tree)[0].text.strip() \
if len(self.xpath_collection['id'](tree)) else None
except:
data['field_of_study'] = None
try:
data['start_date'] = self.xpath_collection['start-date'](tree)[0].text.strip() \
if len(self.xpath_collection['id'](tree)) else None
except:
data['start_date'] = None
try:
data['end_date'] = self.xpath_collection['end-date'](tree)[0].text.strip() \
if len(self.xpath_collection['id'](tree)) else None
except:
data['end_date'] = None
try:
data['degree'] = self.xpath_collection['degree'](tree)[0].text.strip() \
if len(self.xpath_collection['id'](tree)) else None
except:
data['degree'] = None
try:
data['activities'] = self.xpath_collection['activities'](tree)[0].text.strip() \
if len(self.xpath_collection['id'](tree)) else None
except:
data['activities'] = None
results = mappers.Education(data, tree) results = mappers.Education(data, tree)
return results return results

0 comments on commit 01023eb

Please sign in to comment.