Commits

Matthew Schinckel committed 6efcdde

Initial import

Comments (0)

Files changed (21)

Empty file added.

wordlist/__init__.py

Empty file added.

wordlist/data/Family-Names.gz

Binary file added.

wordlist/data/Given-Names.gz

Binary file added.

wordlist/data/Roget.words.gz

Binary file added.

wordlist/data/Unabr.dict.gz

Binary file added.

wordlist/data/Unix.dict.gz

Binary file added.

wordlist/data/animals.gz

Binary file added.

wordlist/data/colours.gz

Binary file added.

wordlist/data/female-names.gz

Binary file added.

wordlist/data/junk.gz

Binary file added.

wordlist/data/male-names.gz

Binary file added.

wordlist/data/other-names.gz

Binary file added.

wordlist/data/plants.gz

Binary file added.

wordlist/data/shapes.gz

Binary file added.

wordlist/data/special.eng.gz

Binary file added.

wordlist/data/sports.gz

Binary file added.

wordlist/data/verbs.gz

Binary file added.

wordlist/data/words-english.gz

Binary file added.

wordlist/helpers.py

+import gzip
+import random
+
+MALE_NAMES = gzip.open('data/male-names.gz').read().strip().split('\n')
+FEMALE_NAMES = gzip.open('data/female-names.gz').read().strip().split('\n')
+LAST_NAMES = gzip.open('data/Family-names.gz').read().strip().split('\n')
+
+WORDS = gzip.open('data/Unabr.dict.gz').read().strip().split('\n')
+
+WORD_TYPES = {
+    'animal': gzip.open('data/animals.gz').read().strip().split('\n'),
+    'plant': gzip.open('data/plants.gz').read().strip().split('\n'),
+    'colour': gzip.open('data/colours.gz').read().strip().split('\n'),
+    'shape': gzip.open('data/shapes.gz').read().strip().split('\n'),
+    'verb': gzip.open('data/verbs.gz').read().strip().split('\n'),
+}
+
+FIRST_NAMES = {
+    None: MALE_NAMES + FEMALE_NAMES,
+    'male': MALE_NAMES,
+    'female': FEMALE_NAMES
+}
+
+def digits(length=3):
+    result = []
+    for i in range(length):
+        result.append(str(random.randint(0,9)))
+    return "".join(result)
+    
+def first_name(gender=None):
+    return random.choice(FIRST_NAMES[gender and gender.lower()]).title()
+
+def last_name():
+    return random.choice(LAST_NAMES).title()
+    
+def generate_full_name(gender=None):
+    return first_name(gender) + ' ' + last_name()
+
+def generate_passphrase(words=4):
+    result = []
+    for i in range(words):
+        result.append(random.choice(WORDS))
+    return " ".join(result)
+
+def generate_nice_passphrase(*terms):
+    result = []
+    for term in terms:
+        result.append(random.choice(WORD_TYPES[term.lower()]))
+    return " ".join(result)

wordlist/models.py

Empty file added.