Browse Source

Try to fix lol xpath in python 2.6

pull/130/head
Florian Mounier 11 years ago
parent
commit
6e7e028308
  1. 17
      pygal/graph/frenchmap.py

17
pygal/graph/frenchmap.py

@ -223,13 +223,22 @@ class FrenchMapDepartments(Graph):
ratio = 1 ratio = 1
else: else:
ratio = .3 + .7 * (value - min_) / (max_ - min_) ratio = .3 + .7 * (value - min_) / (max_ - min_)
areae = map.findall( try:
".//*[@class='%s%s %s map-element']" % ( areae = map.findall(
self.area_prefix, area_code, ".//*[@class='%s%s %s map-element']" % (
self.kind)) self.area_prefix, area_code,
self.kind))
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)
if not areae: if not areae:
continue continue
for area in areae: for area in areae:
cls = area.get('class', '').split(' ') cls = area.get('class', '').split(' ')
cls.append('color-%d' % i) cls.append('color-%d' % i)

Loading…
Cancel
Save