Views

class proton.views.BasicView
abstractmethod display_error(message: str) None

Display an error message. No action is expected from user.

Parameters:

message (str) – Message to display

abstractmethod display_notice(message: str) None

Display a message. No action is expected from user.

Parameters:

message (str) – Message to display

abstractmethod display_session_list(sessions: list['Session'], ask_to_select_one: bool = False) 'Session' | None

Display a list of Sessions, and optionally ask the user to select one of them.

Parameters:
  • sessions (list[Session]) – List of sessions

  • ask_to_select_one (bool, optional) – ask user to select a session, defaults to False

Returns:

the session selected by user (if asked for it), None otherwise (or if user has cancelled)

Return type:

Optional[Session]

abstractmethod ask_credentials(ask_login: bool = False, ask_password: bool = False, ask_2fa: bool = False) tuple[str | None, str | None, str | None]

Ask user for credentials.

Parameters:
  • ask_login (bool, optional) – Ask for user name, defaults to False

  • ask_password (bool, optional) – Ask for the password, defaults to False

  • ask_2fa (bool, optional) – Ask for a 2FA code, defaults to False

Returns:

A tuple (login, password, 2fa). Values are None if not asked from the user, or if user cancelled.

Return type:

tuple[Optional[str], Optional[str], Optional[str]]

class proton.views.basiccli.BasicCLIView

Implementation of proton.views.BasicView for a CLI. It’s really just print + input calls.

display_error(message: str) None

Display an error message. No action is expected from user.

Parameters:

message (str) – Message to display

display_notice(message: str) None

Display a message. No action is expected from user.

Parameters:

message (str) – Message to display

display_session_list(sessions: list['Session'], ask_to_select_one: bool = False) None

Display a list of Sessions, and optionally ask the user to select one of them.

Parameters:
  • sessions (list[Session]) – List of sessions

  • ask_to_select_one (bool, optional) – ask user to select a session, defaults to False

Returns:

the session selected by user (if asked for it), None otherwise (or if user has cancelled)

Return type:

Optional[Session]

ask_credentials(ask_login: bool = False, ask_password: bool = False, ask_2fa: bool = False) tuple[str | None, str | None, str | None]

Ask user for credentials.

Parameters:
  • ask_login (bool, optional) – Ask for user name, defaults to False

  • ask_password (bool, optional) – Ask for the password, defaults to False

  • ask_2fa (bool, optional) – Ask for a 2FA code, defaults to False

Returns:

A tuple (login, password, 2fa). Values are None if not asked from the user, or if user cancelled.

Return type:

tuple[Optional[str], Optional[str], Optional[str]]