skidl.part_query module¶
Functions for finding/displaying parts and footprints.
This module provides utilities to search for electronic parts and footprints across libraries, and to display their details. It includes support for regular expression searches and filtering on different properties.
- class skidl.part_query.PartSearchDB(db_dir=None, db_name=None, tool=None)[source]¶
Bases:
objectManage a parts search SQLite database.
- The DB contains two tables:
libraries(lib_file TEXT PRIMARY KEY, mtime REAL)
parts(id INTEGER PRIMARY KEY, part_name TEXT, lib_file TEXT, search_text TEXT)
The DB path is taken from skidl.config.part_search_db_dir. If that attribute is not present, defaults to the current directory.
- add_lib(lib_path, tool=None)[source]¶
Parse the library file and insert parts into parts table. Update library mtime. lib_path should be an absolute path (or something SchLib can use). If the library is already in the database, then update it and all its parts.
- add_libs(*lib_files)[source]¶
Add or replace libraries listed in lib_files (iterable of filenames). Each lib is added or updated in the libraries table and its parts are added or updated in the parts table.
- load_from_lib_search_paths()[source]¶
Load all libraries from the current skidl.lib_search_paths for the current tool.
- rmv_libs(*lib_files)[source]¶
Remove libraries listed in lib_files (iterable of filenames). Each lib and its parts are removed from the database.
- skidl.part_query.search(terms, tool=None, fmt=None, file=None)¶
Print a list of parts with the regex terms within their name, alias, description or keywords.
Searches through all available libraries for parts matching the given terms and prints the results to the console.
- Parameters:
terms (str) – Search terms separated by spaces (AND) or | (OR) to match against part attributes.
tool (str, optional) – The ECAD tool format for the libraries to search. Defaults to the currently configured tool.
fmt (str, optional) – A format string for displaying each part. Defaults to “{lib_name}: {part_name} ({description})”.
file (file-like object, optional) – The output stream to write results to. Defaults to sys.stdout.
- Returns:
Results are printed to the console.
- Return type:
None
- skidl.part_query.search_footprints(terms, tool=None)[source]¶
Print a list of footprints with the regex term within their description/tags.
Searches through all available footprint libraries for footprints matching the given terms and prints the results to the console.
- skidl.part_query.search_footprints_iter(terms, tool=None)[source]¶
Return an iterator over footprints that match the regex terms.
This generator function yields information about libraries being searched and footprints found that match the search terms.
- Parameters:
- Yields:
tuple –
- Either progress information as (“LIB”, lib_name, index, total)
or footprint information as (“MODULE”, lib_name, module_text, module_name).
- skidl.part_query.search_parts(terms, tool=None, fmt=None, file=None)[source]¶
Print a list of parts with the regex terms within their name, alias, description or keywords.
Searches through all available libraries for parts matching the given terms and prints the results to the console.
- Parameters:
terms (str) – Search terms separated by spaces (AND) or | (OR) to match against part attributes.
tool (str, optional) – The ECAD tool format for the libraries to search. Defaults to the currently configured tool.
fmt (str, optional) – A format string for displaying each part. Defaults to “{lib_name}: {part_name} ({description})”.
file (file-like object, optional) – The output stream to write results to. Defaults to sys.stdout.
- Returns:
Results are printed to the console.
- Return type:
None
- skidl.part_query.show(lib, part_name, tool=None)¶
Print the I/O pins for a given part in a library.
Creates a template Part object that can be inspected to see its pins and properties.
- Parameters:
- Returns:
A template Part object if found, otherwise None.
- Return type:
