Skip to main content

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 file
  • sexp: 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 symbol
  • modify_properties(symbol_name: str, new_properties: dict[str, str]) -> None: Update symbol properties
  • derive_symbol_from(new_name: str, template_name: str, properties: dict[str, str]) -> None: Create derived symbol
  • delete_symbol(symbol_name: str) -> None: Remove a symbol from the library
  • get_symbol_names() -> list[str]: Get list of all symbol names
  • write_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kicad_symlib_utility-1.0.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kicad_symlib_utility-1.0.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file kicad_symlib_utility-1.0.0.tar.gz.

File metadata

File hashes

Hashes for kicad_symlib_utility-1.0.0.tar.gz
Algorithm Hash digest
SHA256 28e6a58f9a2eb4933ea8b391eb65534675ee70daa4db525ba01d61d9b11b3cfb
MD5 c73c975bd2ed4062dd8fd6a784dc27a7
BLAKE2b-256 97a0009ed08265ba7155ffec5c468594deb95c4a55e8a4748c966a5ab15c21ae

See more details on using hashes here.

File details

Details for the file kicad_symlib_utility-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for kicad_symlib_utility-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5b708df03138657c03986a3f427809f7910883497a7bca8302c7de1089d47d5
MD5 6abeaeb2e4e89e2974481524fc135015
BLAKE2b-256 88d9baee282d73d788eb2b4e360c72707ce34172191e96546d4af4ca2b5d8baf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page