summaryrefslogtreecommitdiffstats
path: root/solenv/bin/constructors.py
blob: 1237da17142dad8253bc3ba4b4768795dd1b477c (plain)
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
#!/usr/bin/env python3

# Call $0 <file with a list of component file paths>
# Dumps all the implementing constructors to stdout

import xml.sax
import os.path
import sys

constructors = list()

class ComponentHandler(xml.sax.ContentHandler):
    def startElement(self, tag, attributes):
        if tag == "implementation" and "constructor" in attributes:
            constructors.append(attributes["constructor"])

if __name__ == "__main__":
    parser = xml.sax.make_parser()
    parser.setFeature(xml.sax.handler.feature_namespaces, 0)
    parser.setContentHandler(ComponentHandler())
    for filename in sys.argv[1:]:
        with open(filename, "r") as components_listfile:
            for line in components_listfile:
                for component_filename in line.strip().split():
                    parser.parse(component_filename)
    constructors.sort()
    print("\n".join(constructors))