diff --git a/src/wikitextprocessor/core.py b/src/wikitextprocessor/core.py index 413dcb36..d96f7c08 100644 --- a/src/wikitextprocessor/core.py +++ b/src/wikitextprocessor/core.py @@ -283,6 +283,7 @@ class Wtp: "wiki_notices", # WIKI error messages "wikidata_session", "linktrailing_re", + "quiet_output", # Prevent errors printed to stdout ) def __init__( @@ -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) @@ -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 @@ -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)))