From 85feb8c16cd1c00fb57a1f7924d0e282e476147a Mon Sep 17 00:00:00 2001
From: ulif <uli@gnufix.de>
Date: Wed, 28 Jan 2015 09:57:48 +0100
Subject: [PATCH] Use new wordlist.

---
 diceware/diceware.py   |  8 ++------
 tests/test_diceware.py | 28 ++++++++--------------------
 2 files changed, 10 insertions(+), 26 deletions(-)

diff --git a/diceware/diceware.py b/diceware/diceware.py
index 3f48ebb..180116d 100644
--- a/diceware/diceware.py
+++ b/diceware/diceware.py
@@ -26,12 +26,8 @@ def get_wordlist(path):
     """
     result = []
     with open(path, 'r') as fd:
-        for line in fd.readlines():
-            if not '\t' in line:
-                continue
-            term = line.split('\t')[1].strip()
-            if term != '':  # do not accept empty strings
-                result.append(term)
+        result = [line.strip() for line in fd.readlines()
+                  if line.strip() != '']
     return result
 
 
diff --git a/tests/test_diceware.py b/tests/test_diceware.py
index 273169d..00801af 100644
--- a/tests/test_diceware.py
+++ b/tests/test_diceware.py
@@ -9,35 +9,23 @@ class Test_GetWordList(object):
 
     def test_get_wordlist_en(self):
         # we can get a list of words out of english wordlist.
-        en_src = os.path.join(SRC_DIR, 'wordlist_en.asc')
+        en_src = os.path.join(SRC_DIR, 'wordlist_en.txt')
         en_result = get_wordlist(en_src)
         assert en_result[0] == 'a'
         assert en_result[-1] == '@'
-        assert len(en_result) == 7776
+        assert len(en_result) == 8192
 
     def test_get_wordlist_simple(self, tmpdir):
         # simple wordlists can be created
         in_file = tmpdir.mkdir("work").join("mywordlist")
-        in_file.write("01\ta\n02\tb\n")
+        in_file.write("a\nb\n")
         assert ['a', 'b'] == get_wordlist(in_file.strpath)
 
     def test_get_wordlist_ignore_empty_lines(self, tmpdir):
         # we ignore empty lines in wordlists
         in_file = tmpdir.mkdir("work").join("mywordlist")
-        in_file.write("\n\n\n")
-        assert [] == get_wordlist(in_file.strpath)
-
-    def test_get_wordlist_ignore_non_data(self, tmpdir):
-        # lines without tabs ('\t') are ignored
-        in_file = tmpdir.mkdir("work").join("mywordlist")
-        in_file.write("111111  a\n111112  b\n")
-        assert [] == get_wordlist(in_file.strpath)
-
-    def test_get_wordlist_broken(self, tmpdir):
-        # we handle broken lines gracefully
-        in_file = tmpdir.mkdir("work").join("mywordlist")
-        in_file.write("11\ta\t12\n22\t\n\n33\tc")
-        assert ['a', 'c'] == get_wordlist(in_file.strpath)
+        in_file.write("\n\na\n\n")
+        assert ['a'] == get_wordlist(in_file.strpath)
 
 
 class TestDicewareModule(object):
@@ -56,9 +44,9 @@ class TestDicewareModule(object):
 
     def test_get_wordlist_path_loweres_country_code(self):
         # upper case country codes are lowered
-        assert os.path.basename(get_wordlist_path('de')) == 'wordlist_de.asc'
-        assert os.path.basename(get_wordlist_path('De')) == 'wordlist_de.asc'
-        assert os.path.basename(get_wordlist_path('DE')) == 'wordlist_de.asc'
+        assert os.path.basename(get_wordlist_path('de')) == 'wordlist_de.txt'
+        assert os.path.basename(get_wordlist_path('De')) == 'wordlist_de.txt'
+        assert os.path.basename(get_wordlist_path('DE')) == 'wordlist_de.txt'
 
     def test_get_passphrase(self):
         # we can get passphrases
-- 
GitLab