refactor: use module-level Symbol constants in delete_wire and delete_label
Replace inline Symbol() allocations with the existing _SYM_WIRE/_SYM_PTS/_SYM_XY constants and new _SYM_AT/_SYM_LABEL constants for consistency. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,8 @@ logger = logging.getLogger("kicad_interface")
|
|||||||
_SYM_WIRE = Symbol("wire")
|
_SYM_WIRE = Symbol("wire")
|
||||||
_SYM_PTS = Symbol("pts")
|
_SYM_PTS = Symbol("pts")
|
||||||
_SYM_XY = Symbol("xy")
|
_SYM_XY = Symbol("xy")
|
||||||
|
_SYM_AT = Symbol("at")
|
||||||
|
_SYM_LABEL = Symbol("label")
|
||||||
_SYM_STROKE = Symbol("stroke")
|
_SYM_STROKE = Symbol("stroke")
|
||||||
_SYM_WIDTH = Symbol("width")
|
_SYM_WIDTH = Symbol("width")
|
||||||
_SYM_TYPE = Symbol("type")
|
_SYM_TYPE = Symbol("type")
|
||||||
@@ -543,20 +545,14 @@ class WireManager:
|
|||||||
|
|
||||||
for i, item in enumerate(sch_data):
|
for i, item in enumerate(sch_data):
|
||||||
if not (
|
if not (
|
||||||
isinstance(item, list)
|
isinstance(item, list) and len(item) > 0 and item[0] == _SYM_WIRE
|
||||||
and len(item) > 0
|
|
||||||
and item[0] == Symbol("wire")
|
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Extract pts from the wire s-expression
|
# Extract pts from the wire s-expression
|
||||||
pts_list = None
|
pts_list = None
|
||||||
for part in item[1:]:
|
for part in item[1:]:
|
||||||
if (
|
if isinstance(part, list) and len(part) > 0 and part[0] == _SYM_PTS:
|
||||||
isinstance(part, list)
|
|
||||||
and len(part) > 0
|
|
||||||
and part[0] == Symbol("pts")
|
|
||||||
):
|
|
||||||
pts_list = part
|
pts_list = part
|
||||||
break
|
break
|
||||||
|
|
||||||
@@ -566,7 +562,7 @@ class WireManager:
|
|||||||
xy_points = [
|
xy_points = [
|
||||||
p
|
p
|
||||||
for p in pts_list[1:]
|
for p in pts_list[1:]
|
||||||
if isinstance(p, list) and len(p) >= 3 and p[0] == Symbol("xy")
|
if isinstance(p, list) and len(p) >= 3 and p[0] == _SYM_XY
|
||||||
]
|
]
|
||||||
if len(xy_points) < 2:
|
if len(xy_points) < 2:
|
||||||
continue
|
continue
|
||||||
@@ -631,9 +627,7 @@ class WireManager:
|
|||||||
|
|
||||||
for i, item in enumerate(sch_data):
|
for i, item in enumerate(sch_data):
|
||||||
if not (
|
if not (
|
||||||
isinstance(item, list)
|
isinstance(item, list) and len(item) > 0 and item[0] == _SYM_LABEL
|
||||||
and len(item) > 0
|
|
||||||
and item[0] == Symbol("label")
|
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -647,9 +641,7 @@ class WireManager:
|
|||||||
(
|
(
|
||||||
p
|
p
|
||||||
for p in item[1:]
|
for p in item[1:]
|
||||||
if isinstance(p, list)
|
if isinstance(p, list) and len(p) >= 3 and p[0] == _SYM_AT
|
||||||
and len(p) >= 3
|
|
||||||
and p[0] == Symbol("at")
|
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user