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

Method add_user_library

SLiCAP/schematic/symbol_library.py:351–370  ·  view source on GitHub ↗

Load user symbol libraries from a directory's ``*.svg`` files, AFTER the system bundle, so they ADD new symbols or REDEFINE (override) system ones. Files whose stem is in ``exclude_stems`` are skipped — e.g. a generated subcircuit block symbol, which pairs with a `` .li

(self, directory, exclude_stems=())

Source from the content-addressed store, hash-verified

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
353 the system bundle, so they ADD new symbols or REDEFINE (override) system
354 ones. Files whose stem is in ``exclude_stems`` are skipped — e.g. a
355 generated subcircuit block symbol, which pairs with a ``<name>.lib`` and
356 loads only when its block is placed, never into a fresh schematic."""
357 directory = Path(directory)
358 if not directory.is_dir():
359 return
360 parser = ET.XMLParser(target=ET.TreeBuilder(insert_comments=True))
361 for svg_file in sorted(directory.glob("*.svg")):
362 if svg_file.stem in exclude_stems:
363 continue
364 try:
365 root = ET.parse(svg_file, parser).getroot()
366 except ET.ParseError:
367 continue
368 for g in root.iter(f"{{{SVG_NS}}}g"):
369 if g.get("id") and g.get("data-prefix"):
370 self._add_g(g, svg_file.name, override=True)
371
372 def write_bundle(self, names, path) -> None:
373 """Write the given symbols&#x27; raw <g> definitions to a bundle SVG, so the

Callers 1

_make_libraryMethod · 0.95

Calls 1

_add_gMethod · 0.95

Tested by

no test coverage detected