Created
August 27, 2021 16:29
-
-
Save CptSpaceToaster/55d1842676987c6beb818c585ebe7dbd to your computer and use it in GitHub Desktop.
This file contains hidden or 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