]> git.lizzy.rs Git - nothing.git/blob - devtools/scripts_of_svg.py
Add TODO(#639)
[nothing.git] / devtools / scripts_of_svg.py
1 #!/usr/bin/env python3
2
3 import sys
4 import xml.etree.ElementTree as ET
5 from svg.selectors import *
6 import itertools
7
8
9 def usage():
10     print("Usage: ./scripts_of_svg.py <svg-file-name>")
11
12
13 def scripts_of_rects(svg_root, prefix):
14     return [title.text.split()[0]
15             for rect in svg_rects(svg_root)
16             if rect.attrib['id'].startswith(prefix)
17             for title in rect]
18
19
20 def scripts_of_svg(svg_file_name):
21     svg_tree = ET.parse(svg_file_name)
22     svg_root = svg_tree.getroot()
23     return itertools.chain(
24         scripts_of_rects(svg_root, 'script'),
25         scripts_of_rects(svg_root, 'player'))
26
27
28 if __name__ == '__main__':
29     if len(sys.argv) < 2:
30         usage()
31
32     print(" ".join(scripts_of_svg(sys.argv[1])))