|
11 | 11 |
|
12 | 12 |
|
13 | 13 | class WordList:
|
| 14 | + def __init__(self): |
| 15 | + self.wordlist = [] |
| 16 | + self.wordlist_types = [] |
| 17 | + |
14 | 18 | def get_stdin_wordlist(self):
|
15 | 19 | return list(line for line in sys.stdin.read().splitlines()) \
|
16 | 20 | if not sys.stdin.isatty() else []
|
17 | 21 |
|
18 | 22 | def get_wordlist(self, wordlist_files=None):
|
19 |
| - wordlist = [] |
20 |
| - wordlist_types = [] |
21 | 23 | stdin_words = self.get_stdin_wordlist()
|
| 24 | + default_wordlist_file = DEFAULT_WORDLIST_FILE |
22 | 25 | if stdin_words:
|
23 |
| - wordlist_types.append('stdin') |
24 |
| - wordlist.extend(stdin_words) |
25 |
| - combined_files = wordlist_files or DEFAULT_WORDLIST_FILE |
| 26 | + self.set_words('stdin', stdin_words) |
| 27 | + default_wordlist_file = None |
| 28 | + |
| 29 | + combined_files = wordlist_files or default_wordlist_file |
26 | 30 | combined = get_combined_word_lists(combined_files)
|
27 | 31 | if combined:
|
28 |
| - wordlist_types.append('wordlists: {}'.format( |
29 |
| - ', '.join(combined['file_paths']))) |
30 |
| - wordlist.extend(combined['words']) |
31 |
| - return wordlist, wordlist_types |
| 32 | + words_type = 'wordlists: {}'.format( |
| 33 | + ', '.join(combined['file_paths'])) |
| 34 | + self.set_words(words_type, combined['words']) |
| 35 | + |
| 36 | + return self.wordlist, self.wordlist_types |
| 37 | + |
| 38 | + def set_words(self, words_type, words): |
| 39 | + self.wordlist_types.append(words_type) |
| 40 | + self.wordlist.extend(words) |
0 commit comments