Guest User

Untitled

a guest
Nov 14th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. import subprocess
  2. import os
  3. import sys
  4.  
  5. def copy_to_clip(string):
  6. if(sys.platform == 'darwin'):
  7. cmd='echo \"' + string.strip()+'\" | pbcopy'
  8. else:
  9. cmd='echo \"' + string.strip()+'\" | clip'
  10. return subprocess.check_call(cmd, shell=True)
  11.  
  12. while(1):
  13. userInput = raw_input('Enter the string to switch to sponge case. Ctrl + C or \'!exit!\' to quit program.\n')
  14. if(userInput == '!exit!'):
  15. exit()
  16. newString = ""
  17. previousLower = False
  18. for i in range(0,len(userInput)):
  19. if not userInput[i].isalpha():
  20. newString = newString + userInput[i]
  21. continue
  22. if previousLower:
  23. newString = newString + userInput[i].upper()
  24. previousLower = False
  25. else:
  26. newString = newString + userInput[i].lower()
  27. previousLower = True
  28.  
  29. print newString
  30. try:
  31. copy_to_clip(newString)
  32. print "*Sponge case copied to keyboard*"
  33. except:
  34. continue
  35. #do nothing
Add Comment
Please, Sign In to add comment