Advertisement
Guest User

Letters from argv

a guest
Mar 13th, 2012
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.27 KB | None | 0 0
  1. ## WELCOME TO TAXI'S SHITTY CODING!!! now with 100% more useless comments!
  2. ## 4chan's char limit is 27!
  3. import sys
  4.  
  5. path = sys.argv[1:]     ## this reads the path from the terminal
  6.  
  7. def doit(path):         ## this is the function that will be called at the end of the program
  8.     block2 = (" ", "=", "¯", "_", "*", "|")             ## these are old blocks i used for testing
  9.     blocks = ("░", "█", "▀", "▄", "*", "|")     ## these are the actual blocks that behave oddly in IDLE
  10.  
  11.     parts = ([0,0,0], [3,2,3], [1,2,3], [3,2,2], [1,2,2], [1,0,1], [2,1,2], [0,0,1], [1,2,1], [1,0,0], [1,2,0], [0,1,0], [3,0,1], [2,0,2], [2,2,0], [0,2,2], [2,2,2], [2,0,0], [2,2,1], [0,2,0], [0,2,3], [3,2,0], [0,3,3], [0,0,2], [3,2,1], [2,3,1], [0,3,2], [2,3,2], [2,1,0], [3,3,0], [0,3,0], [1,0,2], [0,2,1], [3,1,3], [3,0,3], [3,3,3], [3,0,0], [0,0,3], [1,3,2], [3,1,0], [2,2,3], [-2], [0,2,0,2,0], [3,0,3,0,3], [2,0,2,0,2], [1,0,1,0,1], [3,3,0,3,0], [2,0,0,2], [1,0,2,1], [1,3,0,1], [2,0,0,0,2], [1,0,2,0,1], [1,3,0,3,1], [-1])
  12.  
  13.     letters = {"a":[20,24,15], "b":[9,2,14], "c":[22,9,15], "d":[7,24,15], "e":[1,4,15], "f":[26,6,19], "g":[1,25,26], "h":[9,2,13], "i":[19,28,16], "j":[23,7,27], "k":[9,38,13], "l":[28,11,16], "m":[-8,-9,-10], "n":[29,5,13], "o":[30,5,19], "p":[29,5,10], "q":[30,31,14], "r":[30,31,17], "s":[3,20,14], "t":[33,11,20], "u":[34,5,16], "v":[34,5,19], "w":[-11,-9,-12], "x":[34,11,13], "y":[34,25,26], "z":[35,26,16], "A":[1,8,13], "B":[2,2,14], "C":[3,9,15], "D":[2,5,14], "E":[4,10,16], "F":[4,10,17], "G":[3,5,15], "H":[5,8,13], "I":[6,11,16], "J":[7,12,16], "K":[5,2,13], "L":[9,9,16], "M":[-2,-3,-4], "N":[-5,-6,-7], "O":[1,5,19], "P":[2,10,17], "Q":[1,5,20], "R":[2,2,13], "S":[3,18,14], "T":[6,11,19], "U":[5,5,16], "V":[5,5,19], "W":[-9,-9,-12], "X":[5,1,13], "Y":[5,11,19], "Z":[18,21,16], " ":[0,0,0], "?":[1,26,30], "!":[11,19,19], "/":[7,11,9], "-":[0,16,0], "_":[0,0,35], "+":[30,6,0], ":":[30,30,0], ">":[36,20,21], "<":[37,21,20], ".":[0,0,19], "1":[39,11,16], "2":[1,26,16], "3":[40,20,14], "4":[24,18,23], "5":[4,40,14], "6":[21,2,19], "7":[18,21,17], "8":[1,1,19], "9":[1,32,19], "0":[1,8,19]}
  14.  
  15.     list1 = []      ## these three lists are the lines of the final document.
  16.     list2 = []      ## the following code will paste blocks in a certain order in each of these lists
  17.     list3 = []
  18.  
  19.     infile = open(str(path[0]), "r")
  20.     string = infile.read()                      ## this stuff defines what to read and where to write (the same place)
  21.     outfile = open(str(path[0]), "w")
  22.  
  23.     for char in str(string):
  24.         if char in letters.keys():              ## i don't remember what "letters.keys()" means, but what this does is:
  25.             indexes = letters[char]             ## "if the characters is in the list "letters", then paste its parts into each list.
  26.             list1 += parts[indexes[0]] + [0]    ##  ...also add a little space between each letter."
  27.             list2 += parts[indexes[1]] + [0]
  28.             list3 += parts[indexes[2]] + [0]
  29.             continue
  30.         elif char == "\n":
  31.             list1 += parts[-13]
  32.             list2 += parts[-13]                 ## if the character is a new line, this pastes a "-2" into the line. (it reads -13 because "-2" is saved in parts as the -13th number, duh!)
  33.             list3 += parts[-13]                 ## the -2 will later be converted into a new line, but on three lines..!
  34.             continue
  35.         else:
  36.             list1 += parts[-1]                  ## if the character is not in the list above or a new line, the character | will be added to all the lists.
  37.             list2 += parts[-1]                  ## this is so you know which character is missing and stuff! If you want you can even add the missing character
  38.             list3 += parts[-1]                  ## so that this won't happen anymore!
  39.  
  40.     masterlist = list1 + [-2] + list2 + [-2] + list3            ## okay here it gets complicated
  41.  
  42.     uberlist = [[]]                                             ## what even is this shit?!
  43.     for index in masterlist:
  44.         if index == -2:
  45.             uberlist += [[]]                                    ## oooh yeah! this is some sort of odd lists system that allowed me to print.
  46.                                                                 ## too bad i remember jackshit on how it works!
  47.     words = len(uberlist) / 3       ## this must be something important
  48.  
  49.     index = 0
  50.     for item in masterlist:
  51.         if item != -2:
  52.             uberlist[index] += [item]
  53.             continue                    ## okay i am completely lost
  54.         index += 1
  55.  
  56.  
  57.     index = 0
  58.     line = blocks[0]
  59.     wordswritten = 0
  60.    
  61.     for item in uberlist:                   ## no way i'm going to try and understand that
  62.         for item in uberlist[index]:
  63.             line += blocks[item]
  64.         outfile.write(line + "\n")
  65.         if index < len(uberlist) - words:
  66.             index += words
  67.             line = blocks[0]
  68.             continue
  69.         else:
  70.             outfile.write(blocks[0] * (len(uberlist[index])+1) + "\n")
  71.             line = blocks[0]
  72.             wordswritten += 1
  73.             index = 0 + wordswritten
  74.  
  75.     outfile.close()
  76.  
  77. doit(path)                      ## this shit here executes everything! Always remember to call back the function when you, uhh... use a function!!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement