4 import xml.etree.ElementTree as ET
5 from svg.selectors import *
10 print("Usage: ./scripts_of_svg.py <svg-file-name>")
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)
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'))
28 if __name__ == '__main__':
32 print(" ".join(scripts_of_svg(sys.argv[1])))