Overlay a frozen .symbols bundle: its symbols OVERRIDE the system ones of the same name (a schematic renders with the symbols it was drawn with, and user-defined symbols win). The bundle is a cache, so a symbol that no longer parses (e.g. an outdated metadata f
(self, path)
| 324 | self._add_g(g, path.name, override=False) |
| 325 | |
| 326 | def add_bundle(self, path) -> list[str]: |
| 327 | """Overlay a frozen <name>.symbols bundle: its symbols OVERRIDE the |
| 328 | system ones of the same name (a schematic renders with the symbols it was |
| 329 | drawn with, and user-defined symbols win). |
| 330 | |
| 331 | The bundle is a cache, so a symbol that no longer parses (e.g. an |
| 332 | outdated metadata format) is skipped rather than aborting the load — the |
| 333 | already-loaded system definition is used in its place. Returns the names |
| 334 | of any skipped symbols so the caller can report them.""" |
| 335 | skipped: list[str] = [] |
| 336 | if not path or not Path(path).is_file(): |
| 337 | return skipped |
| 338 | parser = ET.XMLParser(target=ET.TreeBuilder(insert_comments=True)) |
| 339 | try: |
| 340 | root = ET.parse(str(path), parser).getroot() |
| 341 | except ET.ParseError: |
| 342 | return skipped |
| 343 | for g in root.iter(f"{{{SVG_NS}}}g"): |
| 344 | if g.get("id") and g.get("data-prefix"): |
| 345 | try: |
| 346 | self._add_g(g, Path(path).name, override=True) |
| 347 | except SymbolError: |
| 348 | skipped.append(g.get("id")) |
| 349 | return skipped |
| 350 | |
| 351 | def add_user_library(self, directory, exclude_stems=()) -> None: |
| 352 | """Load user symbol libraries from a directory's ``*.svg`` files, AFTER |
no test coverage detected