From 8b2ce44bbe1456088f72d677a48cb230cf0991e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Solbj=C3=B8rg?= Date: Mon, 1 Apr 2019 22:30:12 +0200 Subject: =?UTF-8?q?chore:=20Move=20switch=20label=20generation=20to=20own?= =?UTF-8?q?=20file=20=F0=9F=A7=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 46 +--------------------------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) (limited to 'main.py') diff --git a/main.py b/main.py index d397f1a..49f717b 100644 --- a/main.py +++ b/main.py @@ -1,48 +1,4 @@ -from gondul import fetch_gondul_switches - -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 = fetch_gondul_switches() - labels = generate_labels(switches) - write_html_to_file(labels) +from switches import make_switch_labels if __name__ == "__main__": -- cgit v1.2.3