A package to process KiCad symbol libraries
Project description
kicad-symlib-utility
A Python package for processing KiCad symbol libraries. This standalone package provides utilities for reading, manipulating, and writing KiCad symbol library files in S-expression format.
Features
- Load and parse KiCad symbol library files (
.kicad_sym) in S-expression format - Access and modify symbol properties programmatically
- Create derived symbols from template symbols with custom properties
- Manage symbol inheritance and template relationships
- Write updated libraries back to disk with proper formatting
- Full error handling with comprehensive validation
Installation
Install using uv (recommended):
uv add kicad-symlib-utility
Or using pip:
pip install kicad-symlib-utility
Quick Start
from pathlib import Path
from kicad_symlib_utility import KiCadSymbolLibrary
# Load a KiCad symbol library
library = KiCadSymbolLibrary(Path("my_symbols.kicad_sym"))
# Get symbol properties
properties = library.get_symbol_properties("R_0805")
print(properties)
# Modify symbol properties
library.modify_properties("R_0805", {"Value": "10k", "Tolerance": "5%"})
# Create a new derived symbol from a template
new_properties = {
"Value": "100k",
"Tolerance": "1%",
"JLCPCB": "C25804"
}
library.derive_symbol_from("R_100k", "R_Template", new_properties)
# Save the modified library
library.write_library(Path("my_symbols_updated.kicad_sym"))
API Reference
KiCadSymbolLibrary
The main class for working with KiCad symbol libraries.
Constructor
KiCadSymbolLibrary(symbol_file: Path, sexp: list | None = None)
symbol_file: Path to the KiCad symbol library filesexp: Optional pre-parsed S-expression (for advanced use cases)
Key Methods
get_symbol_properties(symbol_name: str) -> dict[str, str] | None: Get all properties for a symbolmodify_properties(symbol_name: str, new_properties: dict[str, str]) -> None: Update symbol propertiesderive_symbol_from(new_name: str, template_name: str, properties: dict[str, str]) -> None: Create derived symboldelete_symbol(symbol_name: str) -> None: Remove a symbol from the libraryget_symbol_names() -> list[str]: Get list of all symbol nameswrite_library(output_path: Path | None = None) -> None: Save library to file
KiCadVersionError
Exception raised for unsupported KiCad versions.
Development
This project uses uv for dependency management.
# Install development dependencies
uv sync --dev
# Run tests
uv run pytest
# Run linting
uv run ruff check
uv run ruff format
# Build package
uv build
Requirements
- Python ≥ 3.12
- sexpdata ≥ 1.0.2
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kicad_symlib_utility-1.0.0.tar.gz.
File metadata
- Download URL: kicad_symlib_utility-1.0.0.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28e6a58f9a2eb4933ea8b391eb65534675ee70daa4db525ba01d61d9b11b3cfb
|
|
| MD5 |
c73c975bd2ed4062dd8fd6a784dc27a7
|
|
| BLAKE2b-256 |
97a0009ed08265ba7155ffec5c468594deb95c4a55e8a4748c966a5ab15c21ae
|
File details
Details for the file kicad_symlib_utility-1.0.0-py3-none-any.whl.
File metadata
- Download URL: kicad_symlib_utility-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5b708df03138657c03986a3f427809f7910883497a7bca8302c7de1089d47d5
|
|
| MD5 |
6abeaeb2e4e89e2974481524fc135015
|
|
| BLAKE2b-256 |
88d9baee282d73d788eb2b4e360c72707ce34172191e96546d4af4ca2b5d8baf
|