feat: just did the stuff
Python Lint CI / ruff (push) Successful in 50s
Python Lint CI / ruff-format-check (push) Successful in 49s
Python Test CI / coverage (push) Failing after 50s
Python Lint CI / ty (push) Successful in 50s

This commit is contained in:
2026-06-15 13:17:11 +02:00
parent dcfe91453d
commit a18c066f97
12 changed files with 445 additions and 277 deletions
+35
View File
@@ -0,0 +1,35 @@
import logging
import pathlib
import typing
import unidecode
class WordList:
__slots__ = ["__filepath", "__name", "logger", "words"]
def __init__(self, name: str, path: str, filename: str) -> None:
self.logger: logging.Logger = logging.getLogger(self.__class__.__name__)
self.__name = name
self.__filepath = pathlib.Path(__file__).parent / ".." / path / filename
self.words: list[str] = []
def open(self) -> None:
with self.__filepath.open(encoding="utf-8") as file:
self.words = list(
filter(lambda v: len(v) > 0, map(self.__escape_word, file.readlines()))
)
self.logger.info("[%s] Loaded %d words", self.__name, len(self.words))
def __escape_word(self, word: str) -> str:
return unidecode.unidecode(word.strip()).lower()
def close(self) -> None:
pass
def __enter__(self) -> typing.Self:
self.open()
return self
def __exit__(self, *_: object) -> None:
self.close()