better looking summary

pull/556/head
meisnate12 3 years ago
parent ee2039039c
commit f2ddb6fd46

@ -183,19 +183,19 @@ def regex_first_int(data, id_type, default=None):
else:
raise Failed(f"Regex Error: Failed to parse {id_type} from {data}")
def centered(text, sep=" "):
def centered(text, sep=" ", side_space=True, left=False):
if len(text) > screen_width - 2:
return text
space = screen_width - len(text) - 2
text = f" {text} "
text = f"{' ' if side_space else sep}{text}{' ' if side_space else sep}"
if space % 2 == 1:
text += sep
space -= 1
side = int(space / 2) - 1
final_text = f"{sep * side}{text}{sep * side}"
final_text = f"{text}{sep * side}{sep * side}" if left else f"{sep * side}{text}{sep * side}"
return final_text
def separator(text=None, space=True, border=True, debug=False):
def separator(text=None, space=True, border=True, debug=False, side_space=True, left=False):
sep = " " if space else separating_character
for handler in logger.handlers:
apply_formatter(handler, border=False)
@ -208,9 +208,9 @@ def separator(text=None, space=True, border=True, debug=False):
text_list = text.split("\n")
for t in text_list:
if debug:
logger.debug(f"|{sep}{centered(t, sep=sep)}{sep}|")
logger.debug(f"|{sep}{centered(t, sep=sep, side_space=side_space, left=left)}{sep}|")
else:
logger.info(f"|{sep}{centered(t, sep=sep)}{sep}|")
logger.info(f"|{sep}{centered(t, sep=sep, side_space=side_space, left=left)}{sep}|")
if border and debug:
logger.debug(border_text)
elif border:

@ -354,12 +354,16 @@ def update_libraries(config):
for title in playlist_status:
if len(title) > longest:
longest = len(title)
def print_status(section, status):
logger.info("")
util.separator(f"{section} Summary", space=False, border=False)
logger.info("")
logger.info(f"{'Title':^{longest}} | + | = | - | {'Status':^13}")
breaker = f"{util.separating_character * longest}|{util.separating_character * 5}|{util.separating_character * 5}|{util.separating_character * 5}|"
util.separator(breaker, space=False, border=False, side_space=False, left=True)
for name, data in status.items():
logger.info(f"{name:<{longest}} | {data['status']:<13} | +{data['added']} ={data['unchanged']} -{data['removed']}")
logger.info(f"{name:<{longest}} | {data['added']:^3} | {data['unchanged']:^3} | {data['removed']:^3} | {data['status']}")
if data["errors"]:
for error in data["errors"]:
util.print_multiline(error, info=True)

Loading…
Cancel
Save