Permalink
Browse files

juliengrenier rewrote build_data for LinkedInPositionParser dans lixm…

…l.py to fix bugs when parsing position's company
  • Loading branch information...
1 parent 5765553 commit ccc0c8bef9ad2f953524437f5c7bafb0354f83a7 philgo20 committed Feb 19, 2011
Showing with 5 additions and 8 deletions.
  1. +5 −8 liclient/parsers/lixml.py
@@ -243,20 +243,17 @@ def __init__(self, content):
'id': etree.XPath('id'),
'title': etree.XPath('title'),
'summary': etree.XPath('summary'),
- 'start-date': etree.XPath('start-date'),
- 'end-date': etree.XPath('end-date'),
+ 'start-date': etree.XPath('start-date/year'),
+ 'end-date': etree.XPath('end-date/year'),
'is-current': etree.XPath('is-current'),
'company': etree.XPath('company/name')
}
self.results = self.__build_data(self.tree)
def __build_data(self, tree):
- data = {}
- for n in tree.getchildren():
- if not n.getchildren():
- data[re.sub('-', '_', n.tag)] = n.text
- else:
- data[re.sub('-', '_', n.tag)] = n.getchildren()[0].text
+ data = dict(
+ [(re.sub('-','_',key),self.xpath_collection[key](tree)[0].text) for key in self.xpath_collection if len(self.xpath_collection[key](tree)) > 0]
+ )
results = mappers.Position(data, tree)
return results

0 comments on commit ccc0c8b

Please sign in to comment.