Skip to content
Snippets Groups Projects
Commit 02ad00b9 authored by ulif's avatar ulif
Browse files

Add wordlist parser.

parent 66af8e1f
No related branches found
No related tags found
No related merge requests found
import os
#: The directory in which wordlists are stored
SRC_DIR = os.path.dirname(__file__)
def get_wordlist(path):
"""Parse file at `path` and build a word list of it.
"""
result = []
with open(path, 'r') as fd:
for line in fd.readlines():
if not '\t' in line:
continue
term = line.split('\t')[1].strip()
result.append(term)
return result
def main():
pass
import os
from diceware.diceware import SRC_DIR, get_wordlist
def test_foo():
assert 1 == 1
def test_get_wordlist_en():
# we can get a list of words out of english wordlist.
en_src = os.path.join(SRC_DIR, 'wordlist_en.asc')
en_result = get_wordlist(en_src)
assert en_result[0] == 'a'
assert en_result[-1] == '@'
assert len(en_result) == 7776
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment