2# +==== BEGIN polyguard =================+
21# CREATION DATE: 20-03-2026
22# LAST Modified: 3:53:29 22-03-2026
24# A module that provides a set of swearwords to listen to when filtering while allowing to toggle on and off different languages.
26# COPYRIGHT: (c) Henry Letellier
27# PURPOSE: This is the file containing the constants of the class.
29# +==== END polyguard =================+
33from pathlib
import Path
34from dataclasses
import dataclass
39MODULE_ROOT = Path(__file__).resolve().parent.parent
43DEFAULT_DB_PATH = MODULE_ROOT /
"data" /
"polyguard.sqlite"
45DEFAULT_SOURCE_WORDS = MODULE_ROOT.parent /
"wordlists"
49DEFAULT_CACHE_MAX_LANGS = 8
54 """This is the class in charge of allowing the user to configure the languages they which to check for.
143 brainrot: bool =
False
144 brainrot_twitch: bool =
False
145 brainrot_tiktok: bool =
False
146 brainrot_gaming: bool =
False
147 brainrot_alpha: bool =
False
148 brainrot_discord: bool =
False
244 BRAINROT =
"brainrot"
245 BRAINROT_TWITCH =
"brainrot_twitch"
246 BRAINROT_TIKTOK =
"brainrot_tiktok"
247 BRAINROT_GAMING =
"brainrot_gaming"
248 BRAINROT_ALPHA =
"brainrot_alpha"
249 BRAINROT_DISCORD =
"brainrot_discord"
254COMMAND_TOKEN: str =
":"
255COMMAND_TOKEN_LENGTH: int = len(COMMAND_TOKEN)
259 "polyguard — interactive mode\n"
260 f
"Type '{COMMAND_TOKEN}help' for a short list of commands, '{COMMAND_TOKEN}man' for more details.\n"
261 f
"Enter a word to test it; '{COMMAND_TOKEN}exit' or '{COMMAND_TOKEN}quit' to leave."
265 f
"Commands (prefix with '{COMMAND_TOKEN}' e.g. '{COMMAND_TOKEN}help'):\n"
266 f
" {COMMAND_TOKEN}help Short help text (this message)\n"
267 f
" {COMMAND_TOKEN}man Longer manual describing usage and options\n"
268 f
" {COMMAND_TOKEN}exit, {COMMAND_TOKEN}quit Leave the REPL\n"
269 f
" {COMMAND_TOKEN}db Show configured DB path\n"
270 " <word> Type a word to check it (no prefix required)\n"
271 f
" {COMMAND_TOKEN}log <on/off> Toggle logging output\n"
272 f
" {COMMAND_TOKEN}langopt <lang> <on/off> Enable/disable a language in your config\n"
273 f
" {COMMAND_TOKEN}langs List languages available in the DB (with counts)\n"
274 f
" {COMMAND_TOKEN}langstatus Show which languages are enabled in your config\n"
275 f
" {COMMAND_TOKEN}word <w> [<lang>] Check a word optionally for a specific language\n"
279 "polyguard manual\n\n"
280 "This REPL accepts single-word queries and returns whether the word\n"
281 "is considered a swearword according to the configured language lists.\n\n"
282 "If started with --db-path, that DB will be used; otherwise the package\n"
283 "default DB is used. You can also pipe words via stdin for batch checks.\n\n"
284 "Command prefixing:\n"
285 " To avoid conflicts with words that match command names, commands must be\n"
286 f
" prefixed with '{COMMAND_TOKEN}' (for example '{COMMAND_TOKEN}langs' or '{COMMAND_TOKEN}langopt en_uk off'). Any input\n"
287 f
" that does not start with '{COMMAND_TOKEN}' is treated as a word to check.\n\n"
288 "Additional commands:\n"
289 f
" {COMMAND_TOKEN}log <on/off> Turn logging on or off for the running session.\n"
290 f
" {COMMAND_TOKEN}langopt <lang> <on/off> Temporarily enable or disable a language in your session.\n"
291 f
" {COMMAND_TOKEN}langs Show languages present in the DB and word counts.\n"
292 f
" {COMMAND_TOKEN}langstatus Show which languages are currently enabled in your config.\n"
293 f
" {COMMAND_TOKEN}word <w> [<lang>] Check <w> in either your current config or a specific language.\n"
296POLY_PROMPT =
"polyguard> "
297STATUS_BLOCKED =
"BLOCKED"
299DB_PATH_FMT =
"DB path: {path}"
301TOKENISER_TABLE = str.maketrans(
'',
'',
'\n\r\t\f')