Make badwordlist optional

Follows up I8e758023b38a4d450a0bf02b3bfc0b5033959be7.

Bug: T277936
Change-Id: I20f896f86875c9b11e8a998bca6e08f8c38554c1
This commit is contained in:
Gergő Tisza 2023-07-28 14:58:57 -07:00
parent 2dda9540a5
commit 3953e838f8
No known key found for this signature in database
GPG key ID: C34FEC97E6257F96
3 changed files with 4 additions and 0 deletions

View file

@ -172,6 +172,8 @@ def pick_word(words, badwordlist, verbose, nwords, min_length, max_length):
sys.exit("Unable to find valid word combinations") sys.exit("Unable to find valid word combinations")
def read_wordlist(filename): def read_wordlist(filename):
if not os.path.isfile(filename):
return []
f = open(filename) f = open(filename)
words = [x.strip().lower() for x in f.readlines()] words = [x.strip().lower() for x in f.readlines()]
f.close() f.close()

View file

@ -189,6 +189,8 @@ def pick_word(words, badwordlist, verbose, nwords, min_length, max_length):
sys.exit("Unable to find valid word combinations") sys.exit("Unable to find valid word combinations")
def read_wordlist(filename): def read_wordlist(filename):
if not os.path.isfile(filename):
return []
f = open(filename) f = open(filename)
words = [x.strip().lower() for x in f.readlines()] words = [x.strip().lower() for x in f.readlines()]
f.close() f.close()