aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.py46
-rw-r--r--switches.py45
2 files changed, 46 insertions, 45 deletions
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 = """<!DOCTYPE html>
-<html><head>
- <style>
- div.a4 {
- font-size: 24em;
- text-align: center;
- @page size: A4 landscape;
-
- /* this is the part that makes each div print per page. */
- page-break-after: always;
- }
- </style>
-</head>
-<body>%s</body></html>
-"""
-switch_label_page = '<div class="a4">%s</div>'
-
-
-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__":
diff --git a/switches.py b/switches.py
new file mode 100644
index 0000000..dbc7ece
--- /dev/null
+++ b/switches.py
@@ -0,0 +1,45 @@
+from gondul import fetch_gondul_switches
+
+switch_label_format = "%(switch_name)s-%(switch_num)s"
+switch_label_layout = """<!DOCTYPE html>
+<html><head>
+ <style>
+ div.a4 {
+ font-size: 24em;
+ text-align: center;
+ @page size: A4 landscape;
+
+ /* this is the part that makes each div print per page. */
+ page-break-after: always;
+ }
+ </style>
+</head>
+<body>%s</body></html>
+"""
+switch_label_page = '<div class="a4">%s</div>'
+
+
+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)