Advertisement
Guest User

BF to GGGGGG

a guest
Jan 31st, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import sys
  2.  
  3. if len(sys.argv) < 2:
  4. coderaw = raw_input("No program selected; input code: ")
  5. else:
  6. try:
  7. f = open(sys.argv[1], 'r')
  8. except IOError:
  9. print "File not found, aborting."
  10. raw_input()
  11. exit()
  12. f_ = True
  13.  
  14. coderaw = f.read()
  15.  
  16. output = ""
  17.  
  18. for char in coderaw:
  19. if char == ">":
  20. output += "G "
  21. elif char == "<":
  22. output += "GG "
  23. elif char == ".":
  24. output += "GGG "
  25. elif char == "+":
  26. output += "GGGG "
  27. elif char == "-":
  28. output += "GGGGG "
  29. elif char == ",":
  30. output += "GGGGGG "
  31. elif char == "[":
  32. output += "GGGGGGG "
  33. elif char == "]":
  34. output += "GGGGGGGG "
  35.  
  36. print output
  37.  
  38. with open(sys.argv[1], 'w') as stream:
  39. stream.write(output)
  40.  
  41. raw_input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement