sam1902

Diceware Compact HTML table generator

Feb 15th, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. from sys import argv
  2. """ Usage:
  3.    python3 dicewareGenHTML.py pathToDicewareList pathToOutputHTMLFile
  4.     diceware list file should be a text file which looks like:
  5.     11111 (tabspace \t) word
  6.     11112 (tabspace \t) otherword
  7.     etc...
  8.     This program outputs an HTML page consisting in a table of all words
  9.     which allows you to then print the said page, which makes paper sheets fulled of words (12 columns)
  10.     and requires less pages to print the list since it compacts it (about 7 pages for the whole for my setup)
  11.  
  12.     Here is the Diceware list I used, be sure to remove the PGP signature at the top and bottom before feeding it in: http://world.std.com/%7Ereinhold/diceware.wordlist.asc
  13. """
  14. dicewareHTMLtable = open(argv[2], 'w')
  15.  
  16. count = 0
  17. html = "<html>\n<body>\n<table>\n<tr>"
  18. for lineDiceware in open(argv[1], 'r'):
  19.     number = lineDiceware.split("\t")[0]
  20.     word   = lineDiceware.split("\t")[1].replace("\n","")
  21.     html += "<td>{}</td>\n".format(number)
  22.     html += "<td>{}</td>\n".format(word)
  23.     count += 1
  24.     if count >= 12:
  25.         count = 0
  26.         html += "</tr>\n<tr>"
  27. html += "</tr>\n</table>\n</body>\n</html>"
  28. dicewareHTMLtable.write(html)
Advertisement
Add Comment
Please, Sign In to add comment