source module#
- class CatalogPart(identity, payload)[source]#
Bases:
objectA part resolved from the catalogue. Implements ResolvedPart.
- Parameters:
identity (PartIdentity)
- identity: PartIdentity#
- materialize(component)[source]#
Attach the landpattern, the symbol, and the LCSC part number.
The LCSCPart is the point of either source: the JLCPCB exporter finds it with decompose(component, LCSCPart), so a design resolved through this chain carries its C-numbers without anyone writing one.
The landpattern is the stdlib generator’s where it builds the case, and the catalogue footprint otherwise. That footprint is bound with the default in-order mapping, which for a polarized part assumes the catalogue draws the anode as pad 1; no part seen so far contradicts that, but one that does would be placed reversed.
- class Catalogues(key, ids)[source]#
Bases:
objectThe catalogues serving one category, and a cache key naming them.
ids is whatever the source numbers a catalogue by; only search and vocabulary look inside it. key names the set in a cache filename and in a provider’s config, so it has to be stable and readable.
- class Row(code, case, mpn, manufacturer, values, stock, price, reported, ranked=dict())[source]#
Bases:
objectOne catalogue row, read into the shape a lockfile entry is built from.
- Parameters:
code (
str) – the LCSC C-number, which both sources carry.case (
str) – the package code as the catalogue spells it.mpn (
str) – manufacturer part number.manufacturer (
str|None) – manufacturer name, or None where the row states none.values (
dict[str,float|int|str|bool|PlainQuantity]) – queryable attributes, being the category’s parameters plus whatever synthetic ones the source adds, such as library.stock (
float) – quantity on hand, for ranking.price (
float|None) – cheapest USD ladder price, or None where the row quotes none.reported (
dict[str,JSON]) – payload fields, which a design sees on the component but cannot query. Snapshots belong here rather than in values.ranked (
dict[str,float|int|str|bool|PlainQuantity]) – ranking-only keys, for an ordering that is not a filter.
- class CatalogSource[source]#
Bases:
CategoryProviderResolve passives against one of the two catalogue APIs.
What either source serves is resistors, ceramic and polarized capacitors, and fixed inductors, in any package the catalogue lists. A case the stdlib generator builds gets its landpattern; any other gets the catalogue’s own footprint, see CatalogPart.materialize. Anything else in the catalogue is declined per query rather than guessed at.
Not a dataclass itself: a source is one, and these two are fields it supplies, so declaring them here would take the first constructor slots and force every source to put its own arguments behind them.
- abstractmethod catalogues(category)[source]#
Which catalogues serve category, or None if this source has none.
- Return type:
- Parameters:
category (Category)
- abstractmethod vocabulary(catalogues)[source]#
The filter vocabulary for a set of catalogues. One request.
- Return type:
- Parameters:
catalogues (Catalogues)
- abstractmethod search(query, category, catalogues, table)[source]#
Rows for one query, or a NoMatch naming what could not be asked.
- Return type:
- Parameters:
query (CanonicalQuery)
category (Category)
catalogues (Catalogues)
table (OptionTable)
- abstractmethod read(row, category, table)[source]#
One row as a Row, or None if it is not a part this source can hand back.
- property extra_keys: frozenset[str]#
Filter keys this source serves beyond the category’s parameters.
- resolve_one(query)[source]#
Answer one query. config and rehydrate are still yours to write.
- Return type:
Resolved|NoMatch|Unsupported|Deny- Parameters:
query (CanonicalQuery)
- rehydrate(identity, payload)[source]#
Rebuild a part from a lockfile entry, without asking the API anything.
The identity carries the case code and the C-number, which is everything materialize needs, so a replay run never touches the network.
- Return type:
- Parameters:
identity (PartIdentity)
- distinct(query, key)[source]#
Values of key in this catalogue’s vocabulary for the category.
Answered from the filter vocabulary rather than from a search, since that is what a catalogue publishes it for: it is the whole catalogue’s set of values, not the ones a particular query happens to reach.
- Return type:
- Parameters:
query (CanonicalQuery)
key (str)
- passive_symbol(category, polarized)[source]#
The symbol passive_geometry gives a part, without its landpattern.
- wants(predicate, value, key)[source]#
Whether a filter asks for value. A missing filter asks for nothing.
- keyword(filters)[source]#
A free-text term pinning the search to one part, when the query names one.
Neither API has an exact-identity filter, so an mpn or an lcsc number goes in as a keyword and the local match does the rest.
- row_value(table, param, text, hint=None)[source]#
One parameter of one row, as an attribute value.
text is the value as the row displays it and hint is a numeric field the row states alongside it, which LCSC has and JLCPCB does not. Both numbers are in the parameter’s own standard unit, which is why the table rather than the row decides what they mean: a capacitance comes back in pF and an inductance in uH.
Three readings, in order of how much they can be trusted. The row’s own number where it has one; the catalogue’s option table, which is where a range such as a tolerance has to be read from because neither source states one numerically on every row; and finally the display text itself, parsed with the unit written in it.
That last one is not a nicety. A parameter can be absent from the filter vocabulary and present on the row - a chip resistor’s rated voltage is on every JLCPCB row and in none of its aggregations - and without it such a value would be dropped rather than merely unsearchable.