Skip to content

Commit

Permalink
skip empty lines
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasByr committed Nov 22, 2023
1 parent b36bf1d commit 1f5884f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/generator/gen.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
from __future__ import annotations

import logging
import re
from itertools import combinations, permutations, product
from math import comb, perm, prod
from typing import Generator

__all__ = ["PasswdGenerator", "TupleGenerator"]


is_whitespace = re.compile(r"\s+").match


class PasswdGenerator:
def __init__(self, filepath: str = "assets/passwd.txt", max_cmb_len=2, do_all: bool = False) -> None:
self.__count: int = None
Expand All @@ -17,7 +23,7 @@ def __init__(self, filepath: str = "assets/passwd.txt", max_cmb_len=2, do_all: b
self.max_cmb_len = max_cmb_len
self.filepath = filepath
with open(filepath, "r", encoding="utf-8") as f:
self.chunks = f.read().splitlines(keepends=False)
self.chunks = [line.strip() for line in f if not is_whitespace(line)]

# bellow is NOT executed if not debug
self.logger.debug("[*] %s loaded with %d elements", filepath, self.count)
Expand Down

0 comments on commit 1f5884f

Please sign in to comment.