Skip to content

Commit

Permalink
Formatting functions for informational, warning and error messages ar…
Browse files Browse the repository at this point in the history
…e defined
  • Loading branch information
iberkun committed Jun 9, 2021
1 parent 8f17d70 commit 65c9044
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions edkrepo/common/ui_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
import git
import colorama

from colorama import Fore
from colorama import Style
from colorama import init
init(autoreset=True)

from edkrepo.common.pathfix import expanduser

def init_color_console(force_color_output):
Expand Down Expand Up @@ -47,6 +52,36 @@ def display_git_output(output_data, verbose=False):
if verbose and output_data[2]:
print(output_data[2])

def print_info_msg(info_msg, header=True):
"""
Displays informational message with (default) or without header.
"""
if header:
info_msg_formatted = "{}{}Info: {}{}{}".format(Style.BRIGHT, Fore.CYAN, Style.RESET_ALL, Fore.CYAN, info_msg)
else:
info_msg_formatted = "{}{}".format(Fore.CYAN, info_msg)
print(info_msg_formatted)

def print_warning_msg(warning_msg, header=True):
"""
Displays warning message with (default) or without header.
"""
if header:
warning_msg_formatted = "{}{}Warning: {}{}{}".format(Style.BRIGHT, Fore.YELLOW, Style.RESET_ALL, Fore.YELLOW, warning_msg)
else:
warning_msg_formatted = "{}{}".format(Fore.YELLOW, warning_msg)
print(warning_msg_formatted)

def print_error_msg(error_msg, header=True):
"""
Displays error message with (default) or without header.
"""
if header:
error_msg_formatted = "{}{}Error: {}{}{}".format(Style.BRIGHT, Fore.RED, Style.RESET_ALL, Fore.RED, error_msg)
else:
error_msg_formatted = "{}{}".format(Fore.RED, error_msg)
print(error_msg_formatted)

def print_safe(input_string):
print(safe_str(input_string))

Expand Down

0 comments on commit 65c9044

Please sign in to comment.