summaryrefslogtreecommitdiffstats
path: root/utils/patchlist.py
blob: bbdd963ba90d403959249297645cbe13f2ed5860 (plain) (blame)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/python3
######################################################
##                                                  ##
##    Outputs patch listing for given showfile      ##
##    Output is in tsv format                       ##
##    v0.1                                          ##
##                                                  ##
##    TODO:                                         ##
##     - add options for selecting output params    ##
##                                                  ##
######################################################


import xml.etree.ElementTree as ET
import sys

namespaces = {"qlc" : "http://www.qlcplus.org/Workspace"}

def parseXML(xml_file):
    tree = ET.ElementTree(file=xml_file)
    ET.register_namespace("qlc", namespaces["qlc"])
    root = tree.getroot()
    fixtures = root.findall('.//qlc:Engine/qlc:Fixture', namespaces)

    print("Address", "Mfctr", "Model", "Mode", "CNAME", sep="\t")
    for fixture in fixtures:
        fixture_Name = fixture.find('.//qlc:Name', namespaces).text
        fixture_Universe = int(fixture.find('.//qlc:Universe', namespaces).text)+1
        fixture_Address = int(fixture.find('.//qlc:Address', namespaces).text)+1
        fixture_Manufacturer = fixture.find('.//qlc:Manufacturer', namespaces).text
        fixture_Model = fixture.find('.//qlc:Model', namespaces).text
        fixture_Mode = fixture.find('.//qlc:Mode', namespaces).text
        fixture_Dip = '{0:010b}'.format(fixture_Address)[::-1] # can show dip switch position, unused 
        print(f"{fixture_Universe}.{fixture_Address}",fixture_Manufacturer, fixture_Model, fixture_Mode, fixture_Name, sep="\t")

if __name__ == "__main__":
    if len(sys.argv) >= 2:
        filename = sys.argv[1]
        parseXML(filename)
    else:
        print("Please specify a patch file to read", file=sys.stderr)
        exit(1)