From 557fd6e697072c0a16c538b5f77db5a069d3ff54 Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Fri, 15 Aug 2025 10:18:18 -0400 Subject: [PATCH] lane lines fixes started --- proxy.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/proxy.py b/proxy.py index 42c5e0b..0e30486 100644 --- a/proxy.py +++ b/proxy.py @@ -1,6 +1,6 @@ from typing import List, Protocol, Tuple, Union -def MakeAttrs(css:str|Tuple[str, ...]|None, id:str|None, attributes: dict[str, str | None] = {}) -> str: +def MakeAttrs(css:str|Tuple[str, ...]|None, id:str|None, attributes: dict[str, str | None]) -> str: if css: attributes['class'] = " ".join(css) if isinstance(css, (list, tuple)) else css if id: @@ -17,8 +17,9 @@ class ComplexProxyLeaf(dict): def __init__(self, name:str): self.name = name def __call__(self, css:str|None = None, id:str|None = None): - self.attrs = MakeAttrs(css, id) - return self + clone = ComplexProxyLeaf(self.name) + clone.attrs = MakeAttrs(css, id, {}) + return clone def __repr__(self) -> str: return f'<{self.name} {self.attrs}/>' @@ -28,29 +29,38 @@ class ComplexProxyBranch(ComplexProxyLeaf): def __init__(self, name:str): self.name = name def __call__(self, css:str|None = None, id:str|None = None): - self.attrs = MakeAttrs(css, id) - return self + clone = ComplexProxyBranch(self.name) + clone.attrs = MakeAttrs(css, id, {}) + return clone def __repr__(self) -> str: - return f'<{self.name} {self.attrs}>' + print("dump", self.attrs) + copy = self.attrs + self.attrs = "" + return f'<{self.name} {copy}>' def __getitem__(self, key:Union[str, 'ComplexProxyBranch', ComplexProxyLeaf, Tuple[Union[str, 'ComplexProxyBranch', ComplexProxyLeaf], ...]]) -> str: if isinstance(key, tuple): children = "".join(str(k) for k in key) else: children = key + print("child", self.attrs) return f'<{self.name} {self.attrs}>{children}' + + IMG = ComplexProxyLeaf("img") BR = ComplexProxyLeaf("br") A = ComplexProxyBranch("a") - print( A [ "click here", BR, + A(css="test"), A(css="www.site.com") [ IMG(id="image.png") ] ] -) \ No newline at end of file +) + +