From 53e7991ea310fc3f5121453de13465d433c899a7 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Mon, 2 Jan 2023 20:56:24 +0100 Subject: [PATCH] Use new f string format in boxesserver well, at least a bit more... --- scripts/boxesserver | 76 ++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 42 deletions(-) diff --git a/scripts/boxesserver b/scripts/boxesserver index e621309..e27b0da 100755 --- a/scripts/boxesserver +++ b/scripts/boxesserver @@ -211,23 +211,22 @@ class BServer: else: langparam = "" - result = [""" + result = [f""" - """ + _("Boxes - %s") % _(name), """ + {_("Boxes - %s") % _(name)} -""", self.scripts % (len(box.argparser._action_groups)-3), """ - + {self.scripts % (len(box.argparser._action_groups)-3)} + -
-

' + _("Boxes.py") + """

+

{_("Boxes.py")}

self-Logo @@ -235,10 +234,10 @@ class BServer:

-

""", _(name), """

-

""", _(box.__doc__) if box.__doc__ else "", """

-
- """ % (action)] +

{_(name)}

+

{_(box.__doc__) if box.__doc__ else ""}

+ + """] groupid = 0 for group in box.argparser._action_groups[3:] + box.argparser._action_groups[:3]: if not group._group_actions: @@ -246,7 +245,7 @@ class BServer: if len(group._group_actions) == 1 and isinstance(group._group_actions[0], argparse._HelpAction): continue prefix = getattr(group, "prefix", None) - result.append('''

%s

\n\n''' % (groupid, groupid, groupid, _(group.title), groupid)) + result.append(f'''

{_(group.title)}

\n\n''') for a in group._group_actions: if a.dest in ("input", "output"): @@ -255,11 +254,11 @@ class BServer: result.append(self.arg2html(a, prefix, defaults, _)) result.append("") groupid += 1 - result.append(""" + result.append(f"""

- - - + + +

@@ -284,14 +283,11 @@ class BServer: result.append(f'''
-''') - - result.append("""
-""" + self.footer(lang) + """ +{self.footer(lang)} - """ ) + ''' ) return (s.encode("utf-8") for s in result) def menu(self, lang): @@ -302,15 +298,16 @@ class BServer: else: langparam = "" - result = [""" + result = [f""" - """ + _("Boxes.py") + """ + {_("Boxes.py")} - """, self.scripts % len(self.groups), """ +""", +f""" {self.scripts % len(self.groups)}
-

""" + _("Boxes.py") + """

+

{_("Boxes.py")}

+

{_("Create boxes and more with a laser cutter!")}

-""" + _("Create boxes and more with a laser cutter!") + """ +{_(''' + Boxes.py is an Open Source box generator written in Python. It features both finished parametrized generators as well as a Python API for writing your own. It features finger and (flat) dovetail joints, flex cuts, holes and slots for screws, hinges, gears, pulleys and much more.''')}

-

-""" + _(""" - Boxes.py is an Open Source box generator written in Python. It features both finished parametrized generators as well as a Python API for writing your own. It features finger and (flat) dovetail joints, flex cuts, holes and slots for screws, hinges, gears, pulleys and much more.""") + """ -

- -
+
self-Logo
@@ -361,17 +356,16 @@ class BServer: docs = " - " + _(box.__doc__) result.append(f"""
  • {_(name)}{docs}
  • """) - result.append(""" -
    -""") - result.append(""" + result.append("\n
    \n") + result.append(f"""

    -""" + self.footer(lang) + """ + +{self.footer(lang)} """) @@ -399,15 +393,13 @@ class BServer: """ def errorMessage(self, name, e, _): - return [ - (""" + return [(f""" - """ + _("Error generating %s") % _(name) + - """ + {_("Error generating %s") % _(name)} -

    """ + _("An error occurred!") + "

    " + +

    {_("An error occurred!")}

    """ + "".join(u"

    %s

    " % html.escape(s) for s in type(u"")(e).split(u"\n")) + """