HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/anaconda3/Lib/site-packages/anaconda_cloud_auth/console.py
from getpass import getpass
from typing import Any
from typing import Protocol


class TConsole(Protocol):
    @staticmethod
    def print(*args: Any, **kwargs: Any) -> None: ...

    @staticmethod
    def input(*args: Any, **kwargs: Any) -> Any: ...


class SimpleConsole:
    """
    A very simple console class to mimic the necessary methods we use from rich,
    in case anaconda_cloud_cli is unavailable.
    """

    @staticmethod
    def print(*args: Any, **kwargs: Any) -> None:
        print(*args, **kwargs)

    @staticmethod
    def input(*args: Any, password: bool = False, **kwargs: Any) -> Any:
        if password:
            return getpass(args[0])
        else:
            return input(args[0])


console: TConsole


try:
    from anaconda_cloud_cli import console  # type: ignore

except ImportError:
    console = SimpleConsole()