Remove useless parentheses

This commit is contained in:
Rotzbua 2023-01-13 15:32:32 +01:00 committed by Florian Festi
parent 0a8dcf0e37
commit 6fac72bebd
11 changed files with 28 additions and 30 deletions

View File

@ -196,17 +196,17 @@ class ArgparseEdgeType:
def html(self, name, default, translate):
options = "\n".join(
("""<option value="%s"%s>%s</option>""" %
"""<option value="%s"%s>%s</option>""" %
(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 """<select name="%s" id="%s" aria-labeledby="%s %s" size="1">\n%s</select>\n""" % (name, name, name+"_id", name+"_description", options)
def inx(self, name, viewname, arg):
return (' <param name="%s" type="optiongroup" appearance="combo" gui-text="%s" gui-description=%s>\n' %
(name, viewname, quoteattr(arg.help or "")) +
''.join((' <option value="%s">%s %s</option>\n' % (
''.join(' <option value="%s">%s %s</option>\n' % (
e, e, self.names.get(e, ""))
for e in self.edges)) +
for e in self.edges) +
' </param>\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

View File

@ -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)

View File

@ -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:

View File

@ -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:

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -62,9 +62,9 @@ class ServoArg:
def html(self, name, default, translate):
options = "\n".join(
("""<option value="%s"%s>%s</option>""" %
"""<option value="%s"%s>%s</option>""" %
(name, ' selected="selected"' if name == default else "",
name) for name in self.servos))
name) for name in self.servos)
return """<select name="%s" size="1">\n%s</select>\n""" % (name, options)

View File

@ -51,7 +51,7 @@ class Boxes2INX:
return ""
val = a.default.split("\n")
input = """<textarea name="%s" cols="%s" rows="%s">%s</textarea>""" % \
(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:

View File

@ -173,12 +173,12 @@ class BServer:
elif a.dest == "layout":
val = (default or a.default).split("\n")
input = """<textarea name="%s" id="%s" aria-labeledby="%s %s" cols="%s" rows="%s">%s</textarea>""" % \
(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(
("""<option value="%s"%s>%s</option>""" %
"""<option value="%s"%s>%s</option>""" %
(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 = """<select name="%s" id="%s" aria-labeledby="%s %s" size="1" >\n%s</select>\n""" % (name, name, name+"_id", name+"_description", options)
else:
input = """<input name="%s" id="%s" aria-labeledby="%s %s" type="text" value="%s" >""" % \
@ -390,8 +390,8 @@ f""" </script>{self.scripts % len(self.groups)}
<li><form><select name="language" onchange='if(this.value != "%s") { this.form.submit(); }'>""" % language + \
("<option value='' selected></option>" if not language else "") + \
"\n".join(
("<option value='%s' %s>%s</option>" % (l, "selected" if l==language else "", l)
for l in self.getLanguages())) + """
"<option value='%s' %s>%s</option>" % (l, "selected" if l==language else "", l)
for l in self.getLanguages()) + """
</select></form></li>
<li><a href="https://florianfesti.github.io/boxes/html/usermanual.html">""" + _("Help") + """</a></li>
<li><a href="https://hackaday.io/project/10649-boxespy">""" + _("Home Page") + """</a></li>