8000 simplify · dragoncoder047/schemascii@02b9c35 · GitHub
[go: up one dir, main page]

Skip to content

Commit 02b9c35

Browse files
simplify
1 parent 44ddaad commit 02b9c35

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

schemascii/utils.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ def fix_number(n: float) -> str:
310310

311311
class XMLClass:
312312
def __getattr__(self, tag: str) -> typing.Callable:
313-
def mk_tag(*contents: str, **attrs: str) -> str:
314-
out = f"<{tag} "
313+
def mk_tag(*contents: str, **attrs: str | bool | float | int) -> str:
314+
out = f"<{tag}"
315315
for k, v in attrs.items():
316316
if v is False:
317317
continue
@@ -323,8 +323,8 @@ def mk_tag(*contents: str, **attrs: str) -> str:
323323
# elif isinstance(v, str):
324324
# v = re.sub(r"\b\d+(\.\d+)\b",
325325
# lambda m: fix_number(float(m.group())), v)
326-
out += f'{k.removesuffix("_").replace("__", "-")}="{v}" '
327-
out = out.rstrip() + ">" + "".join(contents)
326+
out += f' {k.removesuffix("_").replace("__", "-")}="{v}"'
327+
out = out + ">" + "".join(contents)
328328
return out + f"</{tag}>"
329329

330330
return mk_tag
@@ -393,15 +393,10 @@ def find_dots(points: list[tuple[complex, complex]]) -> list[complex]:
393393
for p1, p2 in points:
394394
if p1 == p2:
395395
# Skip zero-length wires
396+
# XXX: there shouldn't be any of these anymore?
396397
continue
397-
if p1 not in seen:
398-
seen[p1] = 1
399-
else:
400-
seen[p1] += 1
401-
if p2 not in seen:
402-
seen[p2] = 1
403-
else:
404-
seen[p2] += 1
398+
seen[p1] = seen.get(p1, 0) + 1
399+
seen[p2] = seen.get(p2, 0) + 1
405400
return [pt for pt, count in seen.items() if count > 3]
406401

407402

0 commit comments

Comments
 (0)
0