-
Notifications
You must be signed in to change notification settings - Fork 5
/
mouseware.py
70 lines (59 loc) · 1.68 KB
/
mouseware.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
import sys
import glob
from os.path import splitext, basename
import random
random = random.SystemRandom()
words = {}
src = "txt/*"
for file in glob.glob(src):
with open(file, 'r') as f:
place = splitext(basename(file))[0]
# using list(set( words )) unique-ifies the words
words[place] = list(set([i.strip() for i in f]))
if '--more' in sys.argv:
sys.argv.remove('--more')
construct = ['article', 'adjective', 'noun', 'verb', 'article', 'adjective', 'noun']
else:
construct = ['adjective', 'noun', 'verb', 'adjective', 'noun']
sentence = []
for place in construct:
sentence.append(random.choice(words[place]))
# todo: --number
if '--number' in sys.argv:
sys.argv.remove('--number')
sys.stderr.write('--number not done yet...\n')
# 'a': '4',
# 'e': '3',
# 'i': '1',
# 'o': '0',
# 'q': '9',
# 's': '5',
# 't': '7',
# 'z': '2'
# todo: --symbol
if '--symbol' in sys.argv:
sys.argv.remove('--symbol')
sys.stderr.write('--symbol not done yet...\n')
# 'a': '@',
# 'b': '|3',
# 'c': '(',
# 'h': '|-|',
# 'i': '!',
# 'k': '|<',
# 'l': '|',
# 't': '+',
# 'v': '\\/',
# 's': '$',
# 'x': '%'
if '--dirty' in sys.argv:
sys.argv.remove('--dirty')
dirty = None
while dirty not in ['dirty_adjective', 'dirty_noun', 'dirty_verb']:
dirty_index = random.randrange(len(construct))
dirty = 'dirty_' + construct[dirty_index]
dirty = random.choice(words[dirty])
sentence[dirty_index] = dirty
if len(sys.argv) > 1:
sys.stderr.write("Unknown options: {0}\n".format(', '.join(sys.argv[1:])))
sys.stdout.write(' '.join(sentence) + "\n")