32 lines
671 B
Python
32 lines
671 B
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
import sys
|
||
|
import json
|
||
|
|
||
|
|
||
|
def get_args():
|
||
|
""" Get command line arguments """
|
||
|
|
||
|
import argparse
|
||
|
parser = argparse.ArgumentParser()
|
||
|
parser.add_argument('wordlist')
|
||
|
parser.add_argument('word_length', type=int)
|
||
|
return parser.parse_args()
|
||
|
|
||
|
|
||
|
def main(args):
|
||
|
""" Entry point for script """
|
||
|
with open(args.wordlist) as fp:
|
||
|
words = [ word.lower() for word in fp.read().split('\n') if len(word) == args.word_length and word.isalpha() ]
|
||
|
|
||
|
print(f"wordlist = {json.dumps(words)}")
|
||
|
|
||
|
return 0
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
try:
|
||
|
sys.exit(main(get_args()))
|
||
|
except KeyboardInterrupt:
|
||
|
sys.exit(0)
|