From 9412fb2e2fcd1bd5ba7069dbc7d1dd583bc5a12b Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Mon, 19 Sep 2022 00:10:27 -0500 Subject: [PATCH] feat: make HELP_SEP an f-string --- src/help.py | 2 +- src/print-ansi.py | 8 ++------ task.mk | 11 ++++------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/help.py b/src/help.py index 252926f..459912f 100644 --- a/src/help.py +++ b/src/help.py @@ -53,7 +53,7 @@ def fmt_goal(goal, msg, max_goal_len, argstr): msg_style = args.msg_style.strip() if args.msg_style else "$(MSG_STYLE)" return ( ansi.style(f" {goal:>{max_goal_len}}", goal_style) - + " $(HELP_SEP) " + + f" $(HELP_SEP) " + ansi.style(msg, msg_style) ) diff --git a/src/print-ansi.py b/src/print-ansi.py index 3bc7c09..39a9825 100644 --- a/src/print-ansi.py +++ b/src/print-ansi.py @@ -2,13 +2,9 @@ #% block name %#print_ansi#% endblock %# #% block script %# ##- '$(ansi_py)' -## - +sep = f"$(HELP_SEP)" codes_names = {getattr(ansi, attr): attr for attr in ansi.__dict__} for code in sorted(codes_names.keys(), key=lambda item: (len(item), item)): - print( - "{:>20} $(HELP_SEP) {} $(HELP_SEP) {}".format( - codes_names[code], code + "******" + ansi.end, repr(code) - ) - ) + print(f"{codes_names[code]:>20} {sep} {code+'*****'+ansi.end} {sep} {repr(code)}") #% endblock %# diff --git a/task.mk b/task.mk index ef21972..cdf9fa6 100644 --- a/task.mk +++ b/task.mk @@ -1,7 +1,7 @@ # }> [github.com/daylinmorgan/task.mk] <{ # # Copyright (c) 2022 Daylin Morgan # MIT License -# version: v22.9.14-18-g1a018e2-dev +# version: v22.9.14-19-g8f875a1-dev # # task.mk should be included at the bottom of your Makefile with `-include .task.mk` # See below for the standard configuration options that should be set prior to including this file. @@ -112,7 +112,7 @@ def fmt_goal(goal, msg, max_goal_len, argstr): msg_style = args.msg_style.strip() if args.msg_style else "$(MSG_STYLE)" return ( ansi.style(f" {goal:>{max_goal_len}}", goal_style) - + " $(HELP_SEP) " + + f" $(HELP_SEP) " + ansi.style(msg, msg_style) ) def fmt_rawmsg(msg, argstr, maxlens): @@ -237,13 +237,10 @@ print(f"""$(2)""") endef define print_ansi_py $(ansi_py) +sep = f"$(HELP_SEP)" codes_names = {getattr(ansi, attr): attr for attr in ansi.__dict__} for code in sorted(codes_names.keys(), key=lambda item: (len(item), item)): - print( - "{:>20} $(HELP_SEP) {} $(HELP_SEP) {}".format( - codes_names[code], code + "******" + ansi.end, repr(code) - ) - ) + print(f"{codes_names[code]:>20} {sep} {code+'*****'+ansi.end} {sep} {repr(code)}") endef define vars_py import os