Source code for pywikibot.userinterfaces._interface_base
"""Abstract base user interface module.
*New in version 6.2.*
"""
#
# (C) Pywikibot team, 2021
#
# Distributed under the terms of the MIT license.
#
import sys
from abc import ABC, abstractmethod
from typing import Any, Union
from pywikibot.backports import List
[docs]class ABUIC(ABC):
"""Abstract base user interface class.
Every user interface should derive from it to ensure that all
required methods are implemented.
"""
[docs] def argvu(self) -> List[str]:
"""Return copy of sys.argv.
Assigned to pywikibot.argvu in bot module
"""
return list(sys.argv)
[docs] def flush(self):
"""Flush cached output.
May be passed to atexit.register() to flush any ui cache.
"""
[docs] @abstractmethod
def init_handlers(self, *args, **kwargs):
"""Initialize the handlers for user output.
Called in bot.init_handlers().
"""
[docs] @abstractmethod
def output(self, *args, **kwargs) -> None:
"""Output text to a stream."""
print(*args, **kwargs) # noqa: T001