From cf5ca630fe3e34172ba1216e7e33d0f284d43ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Solbj=C3=B8rg?= Date: Tue, 2 Apr 2019 19:58:09 +0200 Subject: chore: Move tech support label scripts to own folder. After importing all the scripts from another repo. --- tech-support/labels/switches.py | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tech-support/labels/switches.py (limited to 'tech-support/labels/switches.py') diff --git a/tech-support/labels/switches.py b/tech-support/labels/switches.py new file mode 100644 index 0000000..a218489 --- /dev/null +++ b/tech-support/labels/switches.py @@ -0,0 +1,43 @@ +switch_label_format = "%(switch_name)s-%(switch_num)s" +switch_label_layout = """ + + + +%s +""" +switch_label_page = '
%s
' + + +def generate_label(switch_name, switch_number): + return switch_label_page % switch_label_format % { + "switch_name": switch_name, + "switch_num": switch_number, + } + + +def generate_labels(switches): + labels = list(map(lambda switch: generate_label( + switch[1:].split("-")[0], switch.split("-")[1]), switches)) + + return switch_label_layout % "".join(labels) + + +def write_html_to_file(html, outfile="switch_labels.html"): + with open(outfile, "w") as f: + f.write(html) + print("Wrote labels to '{}'.\nOpen the file in your browser and print it.".format(outfile)) + + +def make_switch_labels(switches, outfile="switch_labels.html"): + print("Generating labels for switches") + labels = generate_labels(switches) + write_html_to_file(labels, outfile=outfile) -- cgit v1.2.3