This commit is contained in:
Ben Harris committed 2018-10-09 02:50:10 -04:00
1 parent a8a5de36f2
commit 58753c7234
38 files changed
+4549 -2523

No files matched your search

+35 -16
View File
@@ -4,26 +4,45 @@ import random
import sys
import argparse
parser = argparse.ArgumentParser(description='Print some random dictionary words.')
parser.add_argument('-d', dest='dictionary', metavar='DICT',
help='supply a dictionary', default='/usr/share/dict/american-english-large')
parser.add_argument('-c', dest='count', type=int,
help='specify how many words you want per line', default=10)
parser.add_argument('-l', dest='lines', type=int,
help='specify how many lines of random words you want', default=1)
parser.add_argument('--no-appos', action='store_true',
help='remove words with appostrophes')
parser.add_argument('--no-proper', action='store_true',
help='remove words that start with a capital letter')
parser = argparse.ArgumentParser(description="Print some random dictionary words.")
parser.add_argument(
"-d",
dest="dictionary",
metavar="DICT",
help="supply a dictionary",
default="/usr/share/dict/american-english-large",
)
parser.add_argument(
"-c",
dest="count",
type=int,
help="specify how many words you want per line",
default=10,
)
parser.add_argument(
"-l",
dest="lines",
type=int,
help="specify how many lines of random words you want",
default=1,
)
parser.add_argument(
"--no-appos", action="store_true", help="remove words with appostrophes"
)
parser.add_argument(
"--no-proper",
action="store_true",
help="remove words that start with a capital letter",
)
args = parser.parse_args()
#print args
# print args
with open(args.dictionary, "r") as wordsfile:
words = wordsfile.readlines()
if(args.no_appos):
words[:] = [word for word in words if word.find('\'') == -1]
if(args.no_proper):
if args.no_appos:
words[:] = [word for word in words if word.find("'") == -1]
if args.no_proper:
words[:] = [word for word in words if not word[0].isupper()]
for _ in range(0, args.lines):
print ' '.join([w.strip("\n") for w in random.sample(words, args.count)])
print(" ".join([w.strip("\n") for w in random.sample(words, args.count)]))