Beispiel #1
0
 def write_alphabytes(self):
     os.makedirs(wordlist_path('alphabytes'), exist_ok=True)
     length_files = {
         length: open(
             wordlist_path_from_name('alphabytes/%s.%d' %
                                     (self.name, length)), 'wb')
         for length in range(2, self.max_indexed_length + 1)
     }
     i = 0
     used = set()
     for slug, freq, text in self.iter_all_by_freq():
         if len(slug) >= 2:
             maxlen = self.max_indexed_length
             abytes = alphabytes(slug)
             if abytes not in used:
                 for length in range(len(slug), maxlen + 1):
                     out = length_files[length]
                     out.write(b'\n')
                     out.write(abytes)
                     used.add(abytes)
     for file in length_files.values():
         file.write(b'\n')
         file.close()
Beispiel #2
0
 def write_greppable_lists(self):
     """
     Separate the words by length and write them into separate files.
     """
     os.makedirs(wordlist_path('greppable'), exist_ok=True)
     length_files = {
         length: open(wordlist_path_from_name('greppable/%s.%d' %
                                              (self.name, length)),
                      'w',
                      encoding='ascii')
         for length in range(1, self.max_indexed_length + 1)
     }
     i = 0
     for slug, freq, text in self.iter_all_by_cromulence():
         length = len(slug)
         if 1 <= length <= self.max_indexed_length:
             out = length_files[length]
             print("%s,%d" % (slug, freq), file=out)
         if i % 10000 == 0:
             print("\t%s,%d" % (slug, freq))
         i += 1
     for file in length_files.values():
         file.close()
Beispiel #3
0
def wordlist_path_from_name(name):
    """
    Get the path to the plain-text form of a wordlist.
    """
    return wordlist_path(name + '.txt')