From 8dac5e5615dfa2ef581cc590e4f452893ccb57f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Solbj=C3=B8rg?= Date: Mon, 1 Apr 2019 22:27:39 +0200 Subject: =?UTF-8?q?chore:=20Add=20old=20scripts=20=E2=98=A0=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- old/switch_labels.py | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 old/switch_labels.py (limited to 'old/switch_labels.py') diff --git a/old/switch_labels.py b/old/switch_labels.py new file mode 100644 index 0000000..867c5ab --- /dev/null +++ b/old/switch_labels.py @@ -0,0 +1,120 @@ +#!/usr/bin/python +#coding: utf-8 +# +# @version: 0.1 +# @date: 19.04.2011 +# +# @description: A quick script to output a html page that prints +# switch labels in the format: - +# i.e: 71-4. One label per page. +# +# NB! only makes odd number labels. +# +# @author: technocake +# Found at: blog.technocake.net +#-------------------------------------------- + +import sys + +###################################### +# Configuration +###################################### +rows = 84 #rows +switches = 4 #switches per row +outFile = "tg-switch-labels-print-me.html" + + +#### CREATIVIA #### +creative_rows = 12 +creative_prepend = "C" + + +output = "" + +# the top of the html page +def head(): + return """ + + + + +""" + +#the bottom of the html page +def tail(): + return "" + +#ONE switch label +def a4(s ): + return "
%s
" % (s, ) + + +def saveToFile(data, fileName): + f = open(fileName, 'w+') + f.write( data ) + f.close() + +# In python 3, raw_input is renamed to input. In python v <3. input does something else. +# this function fixes that +def prompt(text): + try: + return raw_input(text) + except: + try: + return input(text) + + except: + exit() + + +################################################### +# This is where the actual generating takes place +################################################### + + +if __name__ == "__main__": + output += head() + + + #Generating all the labels for the switches + for row in range(1, rows+1, 2): + for SWITCH in range(1, switches+1): + output += a4("%s-%s\n" % (row, SWITCH) ) + + + # Generating all the labels for the CREATIVE area + for row in range(1, creative_rows+1): + output += a4("%s-%s\n" % (creative_prepend, row)) + + + + output += tail() + + # Taking it out to the big tg-world + + if len(sys.argv) > 1: + #Printing to stdout if second argument is passed to the script + print ( output ) + else: + saveToFile(output, outFile) + #normally, this is what happens. Saving it to a new html file + + + print ( """ + Generated labels for %d switches per row and %d rows. \n + The html file is in this folder, and is named %s \n + Pages to print: %d \n\n + """ + % (switches, rows, outFile, (switches*rows)/2 + creative_rows) + ) + + prompt( "Press any key to exit...") \ No newline at end of file -- cgit v1.2.3