Source code for userinterfaces._interface_base
"""Abstract base user interface module.
.. versionadded:: 6.2
"""
#
# (C) Pywikibot team, 2021
#
# Distributed under the terms of the MIT license.
#
from __future__ import annotations
import sys
from abc import ABC, abstractmethod
from typing import Any
[docs]
class ABUIC(ABC):
"""Abstract base user interface class.
Every user interface should derive from it to ensure that all
required methods are implemented.
.. versionadded:: 6.2
"""
[docs]
def argvu(self) -> list[str]:
"""Return copy of sys.argv.
Assigned to pywikibot.argvu in bot module
"""
return list(sys.argv)
[docs]
@abstractmethod
def flush(self) -> None:
"""Flush cached output.
May be passed to atexit.register() to flush any ui cache.
"""
[docs]
@abstractmethod
def init_handlers(self, *args, **kwargs) -> None:
"""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: T201