Last active
November 6, 2018 19:28
-
-
Save CptSpaceToaster/25bb7d467fb01e44ed1714ca0e7a864a 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