From 86a3af8d39293f0f92b2a8474b5f7fa154e72944 Mon Sep 17 00:00:00 2001
From: ulif <uli@gnufix.de>
Date: Fri, 31 Jul 2015 22:11:15 +0200
Subject: [PATCH] Use regular expression to filter files.

---
 diceware/wordlist.py | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/diceware/wordlist.py b/diceware/wordlist.py
index 4201fa8..f237c05 100644
--- a/diceware/wordlist.py
+++ b/diceware/wordlist.py
@@ -42,13 +42,10 @@ def get_wordlist_names():
     for filename in filenames:
         if not os.path.isfile(os.path.join(WORDLISTS_DIR, filename)):
             continue
-        if "_" not in filename:
+        match = RE_VALID_WORDLIST_FILENAME.match(filename)
+        if not match:
             continue
-        if "." not in filename:
-            continue
-        basename = filename.split(".")[0]
-        name = basename.split("_", 1)[1]
-        result.append(name)
+        result.append(match.groups()[0])
     return sorted(result)
 
 
-- 
GitLab