|
TTY OV
1
A cross platform python terminal
|
Functions | |
| int | build_db_from_dir (str source_dir, str db_path) |
| int | main (Optional[list[str]] argv=None) |
Variables | |
| Disp | IDISP = initialise_logger("Generate DB", False) |
# +==== BEGIN polyguard =================+ # LOGO: # input # # @#$%! hello # | | # +--+--+ # | # v # +------------+ # | POLY GUARD | # +------------+ # | | # v v # BLOCKED PASSED # KO OK # /STOP # PROJECT: polyguard # FILE: generate_db.py # CREATION DATE: 21-03-2026 # LAST Modified: 19:51:5 21-03-2026 # DESCRIPTION: # A module that provides a set of swearwords to listen to when filtering while allowing to toggle on and off different languages. # Build-time helper to generate the SQLite DB from plaintext word lists. # # Usage (console script): polyguard-generate-db --source-dir ./wordlists --db-path <path> # # The script expects files named using language codes (e.g. `en_uk.txt`, `fr.txt`). # Files whose stem doesn't match a known `Langs` entry will be stored under `Langs.OTHER`. # /STOP # COPYRIGHT: (c) Henry Letellier # PURPOSE: This is the file in charge of generating the database file. # // AR # +==== END polyguard =================+
| int polyguard.src.generate_db.build_db_from_dir | ( | str | source_dir, |
| str | db_path ) |
Scan directory for .txt files and populate SQLite database.
Scans `source_dir` for .txt wordlist files, normalizes each one, and
inserts the words into the SQLite database at `db_path`. File stems are
mapped to Langs enum values; unmapped stems default to Langs.OTHER.
Args:
source_dir: Path to directory containing .txt wordlist files.
db_path: Path where SQLite database will be created or updated.
Returns:
int: Number of language files processed. Returns 0 if no files found.
Raises:
OSError: When source directory cannot be read.
sqlite3.Error: When database operations fail.
Definition at line 50 of file generate_db.py.
| int polyguard.src.generate_db.main | ( | Optional[list[str]] | argv = None | ) |
CLI entrypoint for database generation from wordlists.
Parses command-line arguments for source directory and output database path,
then invokes build_db_from_dir() to populate the database.
Args:
argv: Optional list of command-line arguments. If None, uses sys.argv.
Returns:
int: Exit code (0 for success).
Definition at line 137 of file generate_db.py.
| Disp polyguard.src.generate_db.IDISP = initialise_logger("Generate DB", False) |
Definition at line 47 of file generate_db.py.