kicad-sch-api 0.3.1__py3-none-any.whl → 0.3.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of kicad-sch-api might be problematic. Click here for more details.
- kicad_sch_api/__init__.py +2 -2
- kicad_sch_api/core/formatter.py +33 -1
- kicad_sch_api/core/parser.py +788 -12
- kicad_sch_api/core/schematic.py +49 -7
- kicad_sch_api/core/types.py +14 -0
- kicad_sch_api/geometry/__init__.py +26 -0
- kicad_sch_api/geometry/font_metrics.py +20 -0
- kicad_sch_api/geometry/symbol_bbox.py +595 -0
- {kicad_sch_api-0.3.1.dist-info → kicad_sch_api-0.3.4.dist-info}/METADATA +1 -1
- {kicad_sch_api-0.3.1.dist-info → kicad_sch_api-0.3.4.dist-info}/RECORD +14 -11
- {kicad_sch_api-0.3.1.dist-info → kicad_sch_api-0.3.4.dist-info}/WHEEL +0 -0
- {kicad_sch_api-0.3.1.dist-info → kicad_sch_api-0.3.4.dist-info}/entry_points.txt +0 -0
- {kicad_sch_api-0.3.1.dist-info → kicad_sch_api-0.3.4.dist-info}/licenses/LICENSE +0 -0
- {kicad_sch_api-0.3.1.dist-info → kicad_sch_api-0.3.4.dist-info}/top_level.txt +0 -0
kicad_sch_api/__init__.py
CHANGED
|
@@ -42,7 +42,7 @@ Advanced Usage:
|
|
|
42
42
|
print(f"Found {len(issues)} validation issues")
|
|
43
43
|
"""
|
|
44
44
|
|
|
45
|
-
__version__ = "0.3.
|
|
45
|
+
__version__ = "0.3.3"
|
|
46
46
|
__author__ = "Circuit-Synth"
|
|
47
47
|
__email__ = "info@circuit-synth.com"
|
|
48
48
|
|
|
@@ -55,7 +55,7 @@ from .library.cache import SymbolLibraryCache, get_symbol_cache
|
|
|
55
55
|
from .utils.validation import ValidationError, ValidationIssue
|
|
56
56
|
|
|
57
57
|
# Version info
|
|
58
|
-
VERSION_INFO = (0, 3,
|
|
58
|
+
VERSION_INFO = (0, 3, 3)
|
|
59
59
|
|
|
60
60
|
# Public API
|
|
61
61
|
__all__ = [
|
kicad_sch_api/core/formatter.py
CHANGED
|
@@ -146,6 +146,9 @@ class ExactFormatter:
|
|
|
146
146
|
self.rules["embedded_fonts"] = FormatRule(inline=True)
|
|
147
147
|
self.rules["page"] = FormatRule(inline=True, quote_indices={1})
|
|
148
148
|
|
|
149
|
+
# Image element
|
|
150
|
+
self.rules["image"] = FormatRule(inline=False, custom_handler=self._format_image)
|
|
151
|
+
|
|
149
152
|
def format(self, data: Any) -> str:
|
|
150
153
|
"""
|
|
151
154
|
Format S-expression data with exact KiCAD formatting.
|
|
@@ -189,7 +192,8 @@ class ExactFormatter:
|
|
|
189
192
|
elif isinstance(element, str):
|
|
190
193
|
# Quote strings that need quoting
|
|
191
194
|
if self._needs_quoting(element):
|
|
192
|
-
|
|
195
|
+
escaped = self._escape_string(element)
|
|
196
|
+
return f'"{escaped}"'
|
|
193
197
|
return element
|
|
194
198
|
elif isinstance(element, float):
|
|
195
199
|
# Custom float formatting for KiCAD compatibility
|
|
@@ -510,6 +514,34 @@ class ExactFormatter:
|
|
|
510
514
|
result += f"\n{indent})"
|
|
511
515
|
return result
|
|
512
516
|
|
|
517
|
+
def _format_image(self, lst: List[Any], indent_level: int) -> str:
|
|
518
|
+
"""Format image elements with base64 data split across lines."""
|
|
519
|
+
indent = "\t" * indent_level
|
|
520
|
+
next_indent = "\t" * (indent_level + 1)
|
|
521
|
+
|
|
522
|
+
result = f"({lst[0]}"
|
|
523
|
+
|
|
524
|
+
# Process each element
|
|
525
|
+
for element in lst[1:]:
|
|
526
|
+
if isinstance(element, list):
|
|
527
|
+
tag = str(element[0]) if element else ""
|
|
528
|
+
if tag == "data":
|
|
529
|
+
# Special handling for data element
|
|
530
|
+
# First chunk on same line as (data, rest on subsequent lines
|
|
531
|
+
if len(element) > 1:
|
|
532
|
+
result += f'\n{next_indent}({element[0]} "{element[1]}"'
|
|
533
|
+
for chunk in element[2:]:
|
|
534
|
+
result += f'\n{next_indent}\t"{chunk}"'
|
|
535
|
+
result += f"\n{next_indent})"
|
|
536
|
+
else:
|
|
537
|
+
result += f"\n{next_indent}({element[0]})"
|
|
538
|
+
else:
|
|
539
|
+
# Regular element formatting
|
|
540
|
+
result += f"\n{next_indent}{self._format_element(element, indent_level + 1)}"
|
|
541
|
+
|
|
542
|
+
result += f"\n{indent})"
|
|
543
|
+
return result
|
|
544
|
+
|
|
513
545
|
|
|
514
546
|
class CompactFormatter(ExactFormatter):
|
|
515
547
|
"""Compact formatter for minimal output size."""
|