MCPcopy Index your code
hub / github.com/SLiCAP/SLiCAP_python / add_bundle

Method add_bundle

SLiCAP/schematic/symbol_library.py:326–349  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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&#x27;s ``*.svg`` files, AFTER

Callers 3

_load_sceneFunction · 0.95
_make_libraryMethod · 0.95
_on_place_subcircuitMethod · 0.80

Calls 1

_add_gMethod · 0.95

Tested by

no test coverage detected