Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/wikitextprocessor/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ class Wtp:
"wiki_notices", # WIKI error messages
"wikidata_session",
"linktrailing_re",
"quiet_output", # Prevent errors printed to stdout
)

def __init__(
Expand All @@ -294,6 +295,7 @@ def __init__(
extension_tags: Optional[dict[str, HTMLTagData]] = None,
parser_function_aliases: dict[str, str] = {},
quiet: bool = False,
quiet_output: bool = False,
):
if isinstance(db_path, str):
self.db_path: Optional[Path] = Path(db_path)
Expand Down Expand Up @@ -355,6 +357,7 @@ def __init__(
self.parser_function_aliases = parser_function_aliases
if not quiet:
logger.setLevel(logging.DEBUG)
self.quiet_output = quiet_output
self.wikidata_session: Session | None = None
# Default regex pattern, will sometimes cause trouble.
# Linktrailing is when you have [[a li]]nk that consumes the
Expand Down Expand Up @@ -494,6 +497,8 @@ def init_namespace_data(self) -> None:
}

def _fmt_errmsg(self, kind: str, msg: str, trace: Optional[str]) -> None:
if self.quiet_output:
return
assert isinstance(kind, str)
assert isinstance(msg, str)
assert isinstance(trace, (str, type(None)))
Expand Down