-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvgtools.py
29 lines (21 loc) · 833 Bytes
/
svgtools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import xml.etree.ElementTree as ET
import maptools
tree = ET.parse('maps/images/europe.svg')
root = tree.getroot()
print(root)
territories, borders, units, occupations = maptools.loadMapJSON('europe.json')
# for b in territories:
# print(b.short)
# for country in root.findall('.//{http://www.w3.org/2000/svg}g[@short="'+b.short+'"]'):
# print("tag: " + str(country.tag))
# print("attr: " + str(country.attrib))
# print("text: " + str(country.text))
# #print(b.)
for o in occupations:
print("bla" + o + occupations[o])
for country in root.findall('.//{http://www.w3.org/2000/svg}g[@short="'+o+'"]/{http://www.w3.org/2000/svg}polygon'):
print("tag: " + str(country.tag))
print("attr: " + str(country.attrib))
print("text: " + str(country.text))
country.set("class", occupations[o])
tree.write('output.svg')