The component library system. More...
Classes | |
class | CommandSource |
Source object representing a pair of symbol-generating commands. More... | |
class | DirectorySource |
Source object representing a directory of symbol files. More... | |
Functions | |
def | sym_filename_filter |
Decide based on filename whether a file in a directory source is considered a symbol. More... | |
def | add_source |
Add a component source to the library. More... | |
def | lookup_source |
Get a component source by name. More... | |
def | uniquify_source_name |
Make sure a source name is unique. More... | |
def | refresh |
Rescan all available component libraries. More... | |
def | reset |
Remove all component library sources. More... | |
def | get_symbol |
Get symbol object for a given source object and symbol name. More... | |
def | invalidate_symbol_data |
Invalidate cached data about a symbol. More... | |
def | search |
Find all symbols matching a pattern. More... | |
def | lookup_symbol_source |
Get source for a given symbol name. More... | |
def | lookup_symbol |
Get symbol object for a given symbol name. More... | |
def | used_symbols0 |
Return a list of symbols used in a revision. More... | |
def | used_symbols1 |
Return a list of symbols used in a revision. More... | |
Variables | |
tuple | Source = collections.namedtuple('Source', ['callback', 'symbols', 'name']) |
Named tuple class for storing data about a particular component source. More... | |
list | _sources = [] |
List of source triples for all known component sources. More... | |
dictionary | _search_cache = {} |
Cache for search results of search. More... | |
dictionary | _symbol_cache = {} |
Symbol data cache. More... | |
load_pixmaps = False | |
Whether to load pixmaps referenced by symbols. More... | |
The component library system.
The component library is made up of a number of component sources, each of which in turn makes available a number of component symbols. Each source is represented by a Python object which implements the methods list()
to retrieve a list of symbol names, and get(symbol)
to retrieve the symbol data for a given symbol name.
There are two predefined source types: a DirectorySource represents a directory on disk containing symbol files, and a CommandSource represents a command in the system PATH
which can generate gEDA symbol data (e.g. from a database).
Each symbol is identified by its name, which is stored in the saved schematic file. The name must be valid for storage in a gEDA schematic file as the "basename" of a "component" object. For symbols from directory sources, the filename of the symbol is taken as the symbol name. For a command source, the name may be any permissible string. Guidelines to follow:
The component database may be queried using search. A revision object containing the symbol data may be obtained using get_symbol. If the source of a symbol isn't known, the symbol data may be requested using the convenience function lookup_symbol.
def xorn.geda.clib.add_source | ( | callback, | |
name | |||
) |
Add a component source to the library.
callback must implement two methods: callback.list()
to return a list of symbol names, and callback.get(symbol)
to return the symbol data for a given a symbol name.
callback | source object which implements list and get |
name | unique descriptive name for the component source |
ValueError | if another source with this name already exists |
def xorn.geda.clib.get_symbol | ( | source, | |
symbol | |||
) |
Get symbol object for a given source object and symbol name.
Returns a xorn.geda.ref.Symbol object containing the symbol called symbol from the component source source.
ValueError | if the source object's get function doesn't return a xorn.storage.Revision or xorn.proxy.RevisionProxy instance |
def xorn.geda.clib.invalidate_symbol_data | ( | source, | |
symbol | |||
) |
def xorn.geda.clib.lookup_source | ( | name | ) |
def xorn.geda.clib.lookup_symbol | ( | name | ) |
Get symbol object for a given symbol name.
Returns the xorn.geda.ref.Symbol object for the first symbol found with the given name. This is a helper function for the schematic load system, as it will always want to load symbols given only their name.
ValueError | if the component was not found |
def xorn.geda.clib.lookup_symbol_source | ( | name | ) |
def xorn.geda.clib.refresh | ( | ) |
def xorn.geda.clib.reset | ( | ) |
def xorn.geda.clib.search | ( | pattern, | |
glob = False |
|||
) |
def xorn.geda.clib.sym_filename_filter | ( | basename | ) |
def xorn.geda.clib.uniquify_source_name | ( | name | ) |
def xorn.geda.clib.used_symbols0 | ( | rev | ) |
Return a list of symbols used in a revision.
The list is free of duplicates and preserves the order of the symbols as they appear first in the file. Each symbol is represented by its actual xorn.geda.ref.Symbol object.
def xorn.geda.clib.used_symbols1 | ( | rev | ) |
Return a list of symbols used in a revision.
Scan a revision looking for symbols, look them up in the library, and return them as a list. Each symbol is represented by a pair (source, symbol)
. The returned list only contains symbols that were found in the library and is sorted in alphabetical order.
dictionary xorn.geda.clib._search_cache = {} |
list xorn.geda.clib._sources = [] |
dictionary xorn.geda.clib._symbol_cache = {} |
xorn.geda.clib.load_pixmaps = False |