From 6fac72bebd5efedb5c6068011c9b0be398c18008 Mon Sep 17 00:00:00 2001 From: Rotzbua Date: Fri, 13 Jan 2023 15:32:32 +0100 Subject: [PATCH] Remove useless parentheses --- boxes/__init__.py | 14 +++++++------- boxes/drawing.py | 12 +++++------- boxes/edges.py | 2 +- boxes/generators/halfbox.py | 4 ++-- boxes/generators/traylayout.py | 4 ++-- boxes/generators/wallchiselholder.py | 2 +- boxes/generators/wallslottedholder.py | 2 +- boxes/pulley.py | 2 +- boxes/servos.py | 4 ++-- scripts/boxes2inkscape | 2 +- scripts/boxesserver | 10 +++++----- 11 files changed, 28 insertions(+), 30 deletions(-) diff --git a/boxes/__init__.py b/boxes/__init__.py index d95090c..83ac3c5 100755 --- a/boxes/__init__.py +++ b/boxes/__init__.py @@ -196,17 +196,17 @@ class ArgparseEdgeType: def html(self, name, default, translate): options = "\n".join( - ("""""" % + """""" % (e, ' selected="selected"' if e == default else "", - translate("%s %s" % (e, self.names.get(e, "")))) for e in self.edges)) + translate("%s %s" % (e, self.names.get(e, "")))) for e in self.edges) return """\n""" % (name, name, name+"_id", name+"_description", options) def inx(self, name, viewname, arg): return (' \n' % (name, viewname, quoteattr(arg.help or "")) + - ''.join((' \n' % ( + ''.join(' \n' % ( e, e, self.names.get(e, "")) - for e in self.edges)) + + for e in self.edges) + ' \n') class BoolArg: @@ -520,7 +520,7 @@ class Boxes: s = s.replace('\n', "\\n") return quote(s) - self.metadata["cli"] = "boxes " + self.__class__.__name__ + " " + " ".join((cliquote(arg) for arg in args)) + self.metadata["cli"] = "boxes " + self.__class__.__name__ + " " + " ".join(cliquote(arg) for arg in args) for key, value in vars(self.argparser.parse_args(args=args)).items(): # treat edge settings separately for setting in self.edgesettings: @@ -2706,7 +2706,7 @@ class Boxes: next_angle = borders[i+1] if isinstance(next_angle, (int, float)) and next_angle < 0: - length_correction = t * math.tan(math.radians((-next_angle / 2))) + length_correction = t * math.tan(math.radians(-next_angle / 2)) else: length_correction = 0.0 l -= length_correction @@ -2772,7 +2772,7 @@ class Boxes: rightsettings.setValues(self.thickness, angle=angle) if angle < 0: - length_correction = t * math.tan(math.radians((-angle / 2))) + length_correction = t * math.tan(math.radians(-angle / 2)) else: length_correction = 0.0 l -= length_correction diff --git a/boxes/drawing.py b/boxes/drawing.py index f205a0e..a3cca35 100644 --- a/boxes/drawing.py +++ b/boxes/drawing.py @@ -533,7 +533,7 @@ Creation date: {date} elif C == "T": m, text, params = c[3:] m = m * Affine.translation(0, -params['fs']) - tm = " ".join((f"{m[i]:.3f}" for i in (0, 3, 1, 4, 2, 5))) + tm = " ".join(f"{m[i]:.3f}" for i in (0, 3, 1, 4, 2, 5)) font, bold, italic = params['ff'] fontweight = ("normal", "bold")[bool(bold)] fontstyle = ("normal", "italic")[bool(italic)] @@ -670,10 +670,9 @@ class PSSurface(Surface): ) elif C == "T": m, text, params = c[3:] - tm = " ".join((f"{m[i]:.3f}" for i in (0, 3, 1, 4, 2, 5))) + tm = " ".join(f"{m[i]:.3f}" for i in (0, 3, 1, 4, 2, 5)) text = text.replace("(", "r\(").replace(")", r"\)") - color = " ".join((f"{c:.2f}" - for c in params["rgb"])) + color = " ".join(f"{c:.2f}" for c in params["rgb"]) align = params.get('align', 'left') f.write(f"/{self.fonts[params['ff']]}-Latin1 findfont\n") f.write(f"{params['fs']} scalefont\n") @@ -704,8 +703,7 @@ class PSSurface(Surface): else rgb_to_svg_color(*path.params["rgb"]) ) if p: # todo: might be empty since text is not implemented yet - color = " ".join((f"{c:.2f}" - for c in path.params["rgb"])) + color = " ".join(f"{c:.2f}" for c in path.params["rgb"]) f.write("newpath\n") f.write("\n".join(p)) f.write("\n") @@ -955,7 +953,7 @@ class LBRN2Surface(Surface): sh.text = "\n " sh.tail = "\n" xf = ET.SubElement(sh, "XForm") - xf.text = " ".join((f"{m[i]:.3f}" for i in (0, 3, 1, 4, 2, 5))) + xf.text = " ".join(f"{m[i]:.3f}" for i in (0, 3, 1, 4, 2, 5)) xf.tail = "\n" else: if self.dbg: print ("4", num) diff --git a/boxes/edges.py b/boxes/edges.py index 334461b..400efb3 100644 --- a/boxes/edges.py +++ b/boxes/edges.py @@ -741,7 +741,7 @@ class CompoundEdge(BaseEdge): return self.types[-1].endwidth() def margin(self): - return max((e.margin() + e.startwidth() for e in self.types)) - self.types[0].startwidth() + return max(e.margin() + e.startwidth() for e in self.types) - self.types[0].startwidth() def __call__(self, length, **kw): if length and abs(length - self.length) > 1E-5: diff --git a/boxes/generators/halfbox.py b/boxes/generators/halfbox.py index 1c569b0..48c79fd 100644 --- a/boxes/generators/halfbox.py +++ b/boxes/generators/halfbox.py @@ -131,7 +131,7 @@ and many more... self.move(x+x2+2*t + self.edges["f"].margin(), h+h1+2*t + self.edges["f"].margin(), "right", False, label="side " + str(i)) if len(self.sy) > 1: - for i in range((len(self.sy) - 1)): + for i in range(len(self.sy) - 1): self.move(x + self.edges["f"].margin(), h + self.edges["f"].margin(), "right", True, label="support " + str(i)) self.polygonWallExt(borders=[x, 90, 0, "f", h, 180-b, 0, "f", l, 180-c, 0, "e"]) if self.Clamping: @@ -146,7 +146,7 @@ and many more... self.rectangularWall(h, width, "eGeF" if self.Mounting else "eeeF", callback=[None, None, None, self.hHoles], move="up", label="side") self.rectangularWall(x, width, "efee", callback=[None, self.xHoles, None, None], move="left only", label="invisible") - for i in range((len(self.sy) - 1)): + for i in range(len(self.sy) - 1): self.move(x + self.edges["f"].margin(), h + self.edges["f"].margin(), "right", True, label="support " + str(i)) self.polygonWallExt(borders=[x, 90, 0, "f", h, 180-b, 0, "f", l, 180-c, 0, "e"]) if self.Clamping: diff --git a/boxes/generators/traylayout.py b/boxes/generators/traylayout.py index 4a99624..603614c 100644 --- a/boxes/generators/traylayout.py +++ b/boxes/generators/traylayout.py @@ -67,10 +67,10 @@ of sizes in x and y direction. Choose how many distances you need in both direct for hwalls, vwalls, floors, y in zip( self.hwalls, self.vwalls, self.floors, self.y): - r.append("".join(("+" + " -"[h] for h in hwalls)) + "+\n") + r.append("".join("+" + " -"[h] for h in hwalls) + "+\n") r.append("".join((" |"[v] + "X "[f] for v, f in zip(vwalls, floors))) + " |"[vwalls[-1]] + " %.1fmm\n" % y) - r.append("".join(("+" + " -"[h] for h in self.hwalls[-1])) + "+\n") + r.append("".join("+" + " -"[h] for h in self.hwalls[-1]) + "+\n") return "".join(r) diff --git a/boxes/generators/wallchiselholder.py b/boxes/generators/wallchiselholder.py index 90614d5..7c38e25 100644 --- a/boxes/generators/wallchiselholder.py +++ b/boxes/generators/wallchiselholder.py @@ -79,7 +79,7 @@ class WallChiselHolder(_WallMountedBox): return not (i % 3) def braces(self): - return sum((self.brace(i) for i in range(self.number+1))) + return sum(self.brace(i) for i in range(self.number+1)) def backCB(self): n = self.number diff --git a/boxes/generators/wallslottedholder.py b/boxes/generators/wallslottedholder.py index 815fca9..0432726 100644 --- a/boxes/generators/wallslottedholder.py +++ b/boxes/generators/wallslottedholder.py @@ -79,7 +79,7 @@ class WallSlottedHolder(_WallMountedBox): return not (i % 3) def braces(self): - return sum((self.brace(i) for i in range(self.number+1))) + return sum(self.brace(i) for i in range(self.number+1)) def backCB(self): n = self.number diff --git a/boxes/pulley.py b/boxes/pulley.py index fc79ca5..113ed47 100644 --- a/boxes/pulley.py +++ b/boxes/pulley.py @@ -147,7 +147,7 @@ class Pulley: m = [[tooth_width_scale, 0, 0], [0, tooth_depth_scale, -tooth_distance_from_centre]] m = mmul(m, rotm(i * 2 * pi / teeth)) - points.extend((vtransl(pt, m) for pt in self.teeth[profile][1:-1])) + points.extend(vtransl(pt, m) for pt in self.teeth[profile][1:-1]) self.drawPoints(points, kerfdir=-1 if insideout else 1) self.boxes.move(total_width, total_width, move) diff --git a/boxes/servos.py b/boxes/servos.py index 12e2e97..b709fab 100644 --- a/boxes/servos.py +++ b/boxes/servos.py @@ -62,9 +62,9 @@ class ServoArg: def html(self, name, default, translate): options = "\n".join( - ("""""" % + """""" % (name, ' selected="selected"' if name == default else "", - name) for name in self.servos)) + name) for name in self.servos) return """\n""" % (name, options) diff --git a/scripts/boxes2inkscape b/scripts/boxes2inkscape index 5bed0a7..6ac91b2 100755 --- a/scripts/boxes2inkscape +++ b/scripts/boxes2inkscape @@ -51,7 +51,7 @@ class Boxes2INX: return "" val = a.default.split("\n") input = """""" % \ - (name, max((len(l) for l in val))+10, len(val)+1, a.default) + (name, max(len(l) for l in val)+10, len(val)+1, a.default) elif a.choices: uniqueChoices = [] for e in a.choices: diff --git a/scripts/boxesserver b/scripts/boxesserver index 0909ed1..ed8759e 100755 --- a/scripts/boxesserver +++ b/scripts/boxesserver @@ -173,12 +173,12 @@ class BServer: elif a.dest == "layout": val = (default or a.default).split("\n") input = """""" % \ - (name, name, name+"_id", name+"_description", max((len(l) for l in val))+10, len(val)+1, default or a.default) + (name, name, name+"_id", name+"_description", max(len(l) for l in val)+10, len(val)+1, default or a.default) elif a.choices: options = "\n".join( - ("""""" % + """""" % (e, ' selected="selected"' if (e == (default or a.default)) or (str(e) == str(default or a.default)) else "", - _(e)) for e in a.choices)) + _(e)) for e in a.choices) input = """\n""" % (name, name, name+"_id", name+"_description", options) else: input = """""" % \ @@ -390,8 +390,8 @@ f""" {self.scripts % len(self.groups)}
  • """ + _("Help") + """
  • """ + _("Home Page") + """