Skip to content

Commit

Permalink
Try to fix lol xpath in python 2.6 #2
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxxxzero committed Jun 5, 2014
1 parent 6e7e028 commit 55e8f3d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
10 changes: 6 additions & 4 deletions pygal/graph/frenchmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,12 @@ def _plot(self):
except SyntaxError:
# Python 2.6 (you'd better install lxml)
areae = []
for e in map:
if '%s%s' % (
self.area_prefix, area_code) in e['class']:
areae.append(e)
for g in map:
for e in g:
if '%s%s' % (
self.area_prefix, area_code
) in e.attrib.get('class', ''):
areae.append(e)

if not areae:
continue
Expand Down
11 changes: 10 additions & 1 deletion pygal/graph/supranationalworldmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,16 @@ def _plot(self):
ratio = 1
else:
ratio = .3 + .7 * (value - min_) / (max_ - min_)
country = map.find('.//*[@id="%s"]' % country_code)

try:
country = map.find('.//*[@id="%s"]' % country_code)
except SyntaxError:
# Python 2.6 (you'd better install lxml)
country = None
for e in map:
if e.attrib.get('id', '') == country_code:
country = e

if country is None:
continue
cls = country.get('class', '').split(' ')
Expand Down
11 changes: 10 additions & 1 deletion pygal/graph/worldmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,16 @@ def _plot(self):
ratio = 1
else:
ratio = .3 + .7 * (value - min_) / (max_ - min_)
country = map.find('.//*[@id="%s"]' % country_code)

try:
country = map.find('.//*[@id="%s"]' % country_code)
except SyntaxError:
# Python 2.6 (you'd better install lxml)
country = None
for e in map:
if e.attrib.get('id', '') == country_code:
country = e

if country is None:
continue
cls = country.get('class', '').split(' ')
Expand Down

0 comments on commit 55e8f3d

Please sign in to comment.