Browse Source

Try to fix lol xpath in python 2.6 #2

pull/130/head
Florian Mounier 11 years ago
parent
commit
55e8f3d177
  1. 10
      pygal/graph/frenchmap.py
  2. 11
      pygal/graph/supranationalworldmap.py
  3. 11
      pygal/graph/worldmap.py

10
pygal/graph/frenchmap.py

@ -231,10 +231,12 @@ class FrenchMapDepartments(Graph):
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

11
pygal/graph/supranationalworldmap.py

@ -56,7 +56,16 @@ class SupranationalWorldmap(Worldmap):
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(' ')

11
pygal/graph/worldmap.py

@ -74,7 +74,16 @@ class Worldmap(Graph):
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(' ')

Loading…
Cancel
Save