|
|
|
@ -1,5 +1,31 @@ |
|
|
|
|
|
|
|
def choose_color(last_color_index): |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
Selects the next color in a predefined sequence of colors. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
|
|
|
|
last_color_index (int): The index of the last color used. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns: |
|
|
|
|
|
|
|
tuple: A tuple containing the ANSI escape code for the selected color (str) |
|
|
|
|
|
|
|
and the index of the selected color (int). |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
colors = { |
|
|
|
|
|
|
|
"blue": "\033[94m", |
|
|
|
|
|
|
|
"green": "\033[92m", |
|
|
|
|
|
|
|
"yellow": "\033[93m", |
|
|
|
|
|
|
|
"red": "\033[91m", |
|
|
|
|
|
|
|
"purple": "\033[95m", |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
color_keys = list(colors.keys()) |
|
|
|
|
|
|
|
color_index = (last_color_index + 1) % len(color_keys) |
|
|
|
|
|
|
|
color = color_keys[color_index] |
|
|
|
|
|
|
|
return colors[color], color_index |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def print_green(*args): |
|
|
|
def print_green(*args): |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
Prints the provided arguments in green. |
|
|
|
|
|
|
|
""" |
|
|
|
text = "" |
|
|
|
text = "" |
|
|
|
for arg in args: |
|
|
|
for arg in args: |
|
|
|
text += str(arg) + " " |
|
|
|
text += str(arg) + " " |
|
|
|
@ -7,6 +33,9 @@ def print_green(*args): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def print_red(*args): |
|
|
|
def print_red(*args): |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
Prints the provided arguments in red. |
|
|
|
|
|
|
|
""" |
|
|
|
text = "" |
|
|
|
text = "" |
|
|
|
for arg in args: |
|
|
|
for arg in args: |
|
|
|
text += str(arg) + " " |
|
|
|
text += str(arg) + " " |
|
|
|
@ -14,6 +43,9 @@ def print_red(*args): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def print_yellow(*args): |
|
|
|
def print_yellow(*args): |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
Prints the provided arguments in yellow. |
|
|
|
|
|
|
|
""" |
|
|
|
text = "" |
|
|
|
text = "" |
|
|
|
for arg in args: |
|
|
|
for arg in args: |
|
|
|
text += str(arg) + " " |
|
|
|
text += str(arg) + " " |
|
|
|
@ -21,6 +53,9 @@ def print_yellow(*args): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def print_blue(*args): |
|
|
|
def print_blue(*args): |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
Prints the provided arguments in blue. |
|
|
|
|
|
|
|
""" |
|
|
|
text = "" |
|
|
|
text = "" |
|
|
|
for arg in args: |
|
|
|
for arg in args: |
|
|
|
text += str(arg) + " " |
|
|
|
text += str(arg) + " " |
|
|
|
@ -28,26 +63,28 @@ def print_blue(*args): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def print_purple(*args): |
|
|
|
def print_purple(*args): |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
Prints the provided arguments in purple. |
|
|
|
|
|
|
|
""" |
|
|
|
text = "" |
|
|
|
text = "" |
|
|
|
for arg in args: |
|
|
|
for arg in args: |
|
|
|
text += str(arg) + " " |
|
|
|
text += str(arg) + " " |
|
|
|
print(f"\033[95m{text}\033[0m") |
|
|
|
print(f"\033[95m{text}\033[0m") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def choose_color(last_color_index): |
|
|
|
|
|
|
|
colors = { |
|
|
|
|
|
|
|
"blue": "\033[94m", |
|
|
|
|
|
|
|
"green": "\033[92m", |
|
|
|
|
|
|
|
"yellow": "\033[93m", |
|
|
|
|
|
|
|
"red": "\033[91m", |
|
|
|
|
|
|
|
"purple": "\033[95m", |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
color_keys = list(colors.keys()) |
|
|
|
|
|
|
|
color_index = (last_color_index + 1) % len(color_keys) |
|
|
|
|
|
|
|
color = color_keys[color_index] |
|
|
|
|
|
|
|
return colors[color], color_index |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def print_rainbow(*args): |
|
|
|
def print_rainbow(*args): |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
Prints the provided arguments in a rainbow of colors. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
|
|
|
|
*args: Variable length argument list. Each argument can be a string, list, or dictionary. |
|
|
|
|
|
|
|
- If the argument is a list, each element in the list will be printed in a different color. |
|
|
|
|
|
|
|
- If the argument is a dictionary, each key-value pair will be printed in a different color. |
|
|
|
|
|
|
|
- If the argument is a string or any other type, it will be printed in a different color. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns: |
|
|
|
|
|
|
|
None |
|
|
|
|
|
|
|
""" |
|
|
|
color_index = -1 |
|
|
|
color_index = -1 |
|
|
|
text = "" |
|
|
|
text = "" |
|
|
|
for arg in args: |
|
|
|
for arg in args: |
|
|
|
|