@@ -283,6 +283,7 @@ class Wtp:
283283 "wiki_notices" , # WIKI error messages
284284 "wikidata_session" ,
285285 "linktrailing_re" ,
286+ "quiet_output" , # Prevent errors printed to stdout
286287 )
287288
288289 def __init__ (
@@ -294,6 +295,7 @@ def __init__(
294295 extension_tags : Optional [dict [str , HTMLTagData ]] = None ,
295296 parser_function_aliases : dict [str , str ] = {},
296297 quiet : bool = False ,
298+ quiet_output : bool = False ,
297299 ):
298300 if isinstance (db_path , str ):
299301 self .db_path : Optional [Path ] = Path (db_path )
@@ -355,6 +357,7 @@ def __init__(
355357 self .parser_function_aliases = parser_function_aliases
356358 if not quiet :
357359 logger .setLevel (logging .DEBUG )
360+ self .quiet_output = quiet_output
358361 self .wikidata_session : Session | None = None
359362 # Default regex pattern, will sometimes cause trouble.
360363 # Linktrailing is when you have [[a li]]nk that consumes the
@@ -494,6 +497,8 @@ def init_namespace_data(self) -> None:
494497 }
495498
496499 def _fmt_errmsg (self , kind : str , msg : str , trace : Optional [str ]) -> None :
500+ if self .quiet_output :
501+ return
497502 assert isinstance (kind , str )
498503 assert isinstance (msg , str )
499504 assert isinstance (trace , (str , type (None )))
0 commit comments