Created
April 16, 2019 18:16
-
-
Save CptSpaceToaster/79951366e7532b66aa09feaa850c2c61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hONk