Skip to content

Instantly share code, notes, and snippets.

@CptSpaceToaster
Created April 16, 2019 18:16
Show Gist options
  • Save CptSpaceToaster/79951366e7532b66aa09feaa850c2c61 to your computer and use it in GitHub Desktop.
Save CptSpaceToaster/79951366e7532b66aa09feaa850c2c61 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import argparse
import sys
def digest(infile):
for line in infile.readlines():
mock(line)
def mock(line):
res = ''
for word in line.split(' '):
for idx, c in enumerate(word):
if idx % 2 == 0:
res += c.lower()
else:
res += c.upper()
if c not in ['\n']:
res += ' '
print(res, end='')
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Changes case to mock the writer')
parser.add_argument('text', nargs='?', help='Text to mock')
parser.add_argument('-i', '--infile', type=argparse.FileType('r'), default=sys.stdin)
args = parser.parse_args()
if args.text:
mock(args.text + '\n')
else:
digest(args.infile)
@ekatsim
Copy link

ekatsim commented Mar 29, 2020

hONk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment