dav_tools.messages ================== .. py:module:: dav_tools.messages .. autoapi-nested-parse:: Print messages on screen and ask for user input. Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/dav_tools/messages/formatted_text/index /autoapi/dav_tools/messages/utils/index Classes ------- .. autoapisummary:: dav_tools.messages.FormattedText Functions --------- .. autoapisummary:: dav_tools.messages._read_input dav_tools.messages._clear_line dav_tools.messages.message dav_tools.messages.debug dav_tools.messages.info dav_tools.messages.progress dav_tools.messages.error dav_tools.messages.critical_error dav_tools.messages.warning dav_tools.messages.success dav_tools.messages.ask dav_tools.messages.ask_yn dav_tools.messages.ask_continue Package Contents ---------------- .. py:class:: FormattedText(text, *options) Represents text with optional formatting options applied. :param text: The text content to be formatted. :param options: Optional formatting options to be applied to the text. .. py:method:: get_format() Constructs the formatting string based on the provided options. :returns: A string representing the combined formatting options. .. py:method:: reset_format() :staticmethod: Provides the reset formatting string to clear any applied styles. :returns: A string representing the reset formatting option. .. py:function:: _read_input(*format_options, secret = False, file=_sys.stderr) Ask input from a user using specified styling options. :param format_options: Text styling options. :param secret: Whether to hide the input. :param file: Stream to use for output. :returns: User input. .. py:function:: _clear_line(file=_sys.stdout, flush = False) Clears the current line from any text of formatting. Not really suitable for files. :param file: Stream to clear. :param flush: Whether to flush the stream after printing. .. py:function:: message(*text, text_min_len = [], default_text_options = [], additional_text_options = [[]], icon = None, icon_options = [], sep = ' ', end = '\n', file=_sys.stderr) Generic and customizable message. :param text: The message(s) to print. :param text_min_len: Minimum length for each message. Fill the remaining characters with spaces. :param default_text_options: Styling options applied to all messages. :param additional_text_options: Styling options applied to single messages. :param icon: Character to use as icon, between ``[ ]``. :param icon_options: Styling options applied to the icon. :param end: Character to output at the end of the message. :param file: Where to write the message. .. py:function:: debug(*text, color = TextFormat.Color.PURPLE, text_min_len = [], text_options = [[]], file=_sys.stderr) Debugging message, which stands out from all other messages. Each messages has also a unique ID. :param text: The message(s) to print. :param color: Message color. Default = Purple :param text_min_len: Minimum length for each message. Fill the remaining characters with spaces. :param text_options: Styling options applied to single messages. :param file: Where to write the message. .. py:function:: info(*text, text_min_len = [], text_options = [[]], file=_sys.stderr) Message indicating an information. :param text: The message(s) to print. :param text_min_len: Minimum length for each message. Fill the remaining characters with spaces. :param text_options: Styling options applied to single messages. :param file: Where to write the message. .. py:function:: progress(*text, text_min_len = [], text_options = [[]], file=_sys.stderr) Message indicating an action which is still happening. :param text: The message(s) to print. :param text_min_len: Minimum length for each message. Fill the remaining characters with spaces. :param text_options: Styling options applied to single messages. :param file: Where to write the message. .. py:function:: error(*text, text_min_len = [], text_options = [[]], file=_sys.stderr) Message indicating an error. :param text: The message(s) to print. :param text_min_len: Minimum length for each message. Fill the remaining characters with spaces. :param text_options: Styling options applied to single messages. :param file: Where to write the message. .. py:function:: critical_error(*text, text_min_len = [], exit_code = 1, file=_sys.stderr) Message indicating a critical error. The program terminates after showing this message. :param text: The message(s) to print. :param text_min_len: Minimum length for each message. Fill the remaining characters with spaces. :param exit_code: The exit code of the program. :param file: Where to write the message. .. py:function:: warning(*text, text_min_len = [], text_options = [[]], file=_sys.stderr) Message indicating a warning. :param text: The message(s) to print. :param text_min_len: Minimum length for each message. Fill the remaining characters with spaces. :param text_options: Styling options applied to single messages. :param file: Where to write the message. .. py:function:: success(*text, text_min_len = [], text_options = [[]], file=_sys.stderr) Message indicating a successfully completed action. :param text: The message(s) to print. :param text_min_len: Minimum length for each message. Fill the remaining characters with spaces. :param text_options: Styling options applied to single messages. :param file: Where to write the message. .. py:function:: ask(question, end=': ', secret = False, file=_sys.stderr) Prints a question to screen and returns the answer. :param question: The question to print. :param end: Characters to be printed at the end of the question. :param file: Where to write the message. :returns: The user's answer. .. py:function:: ask_yn(text, default_yes = False, file=_sys.stderr) Prints a question asking the user a Yes/No question. Returns the answer as a boolean (Yes = True, No = False). :param text: The message to print. :param default_yes: Automatically accept when pressing Enter. :param file: Where to write the message. .. py:function:: ask_continue(text = None, default_yes = False, file=_sys.stderr) Prints a question asking the user if they want to continue executing the program: a positive answer makes the program continues its normal execution; a negative answer terminates the program. Optionally supports a custom message. :param text: The message to print. :param default_yes: Automatically accept when pressing Enter. :param file: Where to write the message.