Advertisement
DarkPotatoKing

LiteralJejemonConverter.py

Aug 2nd, 2014
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.95 KB | None | 0 0
  1. import random
  2.  
  3. def toLowercaseStr (msg):
  4.     temp = '' #template
  5.  
  6.     for c in msg:
  7.         c = toLowercaseChar(c)
  8.  
  9.         temp += c
  10.  
  11.     return temp
  12.  
  13. def toIntVal (c):
  14.     c = (str)(c)
  15.     return ord(c)
  16.  
  17. def toLowercaseChar(c):
  18.     START = 'A' #range of characters to be checked is from capital A-Z
  19.     END = 'Z'
  20.  
  21.     charIntVal = toIntVal(c)
  22.     startIntVal = toIntVal(START)
  23.     endIntVal = toIntVal(END)
  24.  
  25.     if startIntVal <= charIntVal <= endIntVal:
  26.         charIntVal -= toIntVal('A') - toIntVal('a')
  27.         c = intValToChar(charIntVal)
  28.  
  29.     return c
  30.  
  31. def intValToChar (n):
  32.     n = (int)(n)
  33.     return chr(n)
  34.  
  35. def convertStrToJeje (s):
  36.     temp = ''
  37.  
  38.     for c in s:
  39.         c = (str)(c)
  40.         temp += convertCharToJeje(c)
  41.  
  42.     return temp
  43.  
  44. def convertCharToJeje(c):
  45.     c = toLowercaseChar(c)
  46.     temp = c
  47.  
  48.     if c == 'a':
  49.         temp = getRandomElementFromList(['a','A','@','4'])
  50.     elif c == 'b':
  51.         temp = getRandomElementFromList(['b','B','|3'])
  52.     elif c == 'c':
  53.         temp = getRandomElementFromList(['c','C','(','<','{'])
  54.     elif c == 'd':
  55.         temp = getRandomElementFromList(['d','D','|)','|>'])
  56.     elif c == 'e':
  57.         temp = getRandomElementFromList(['e','E','3'])
  58.     elif c == 'f':
  59.         temp = getRandomElementFromList(['f','F'])
  60.     elif c == 'g':
  61.         temp = getRandomElementFromList(['g','G','6'])
  62.     elif c == 'h':
  63.         temp = getRandomElementFromList(['h','H','|-|','#'])
  64.     elif c == 'i':
  65.         temp = getRandomElementFromList(['i','I','!'])
  66.     elif c == 'j':
  67.         temp = getRandomElementFromList(['j','J'])
  68.     elif c == 'k':
  69.         temp = getRandomElementFromList(['k','K','|<'])
  70.     elif c == 'l':
  71.         temp = getRandomElementFromList(['l','L','1'])
  72.     elif c == 'm':
  73.         temp = getRandomElementFromList(['m','M'])
  74.     elif c == 'n':
  75.         temp = getRandomElementFromList(['n','N'])
  76.     elif c == 'o':
  77.         temp = getRandomElementFromList(['o','O','0'])
  78.     elif c == 'p':
  79.         temp = getRandomElementFromList(['p','P'])
  80.     elif c == 'q':
  81.         temp = getRandomElementFromList(['q','Q','9'])
  82.     elif c == 'r':
  83.         temp = getRandomElementFromList(['r','R',"|2"])
  84.     elif c == 's':
  85.         temp = getRandomElementFromList(['s','S','5'])
  86.     elif c == 't':
  87.         temp = getRandomElementFromList(['t','T','+'])
  88.     elif c == 'u':
  89.         temp = getRandomElementFromList(['u','U','|_|'])
  90.     elif c == 'v':
  91.         temp = getRandomElementFromList(['v','V','\\/'])
  92.     elif c == 'w':
  93.         temp = getRandomElementFromList(['w','W'])
  94.     elif c == 'x':
  95.         temp = getRandomElementFromList(['x','X'])
  96.     elif c == 'y':
  97.         temp = getRandomElementFromList(['y','Y'])
  98.     elif c == 'z':
  99.         temp = getRandomElementFromList(['z','Z'])
  100.  
  101.  
  102.     return temp
  103.  
  104. def getRandomElementFromList(ls):
  105.     return random.choice(ls)
  106.  
  107. s = ''
  108.  
  109. s = raw_input('Enter a string:\n')
  110.  
  111. print 'Jejemon Conversion:\n',convertStrToJeje(s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement