23 from gettext
import gettext
as _
27 SLOTDEF_ATTRIB_DELIMITERS =
',; '
34 found = [i
for i
in (s.find(d, start)
for d
in delim)
if i != -1]
55 value = component_blueprint.get_attribute(
'slot')
67 component_blueprint.error(
68 _(
"non-numeric slot= attribute: %s") % value)
76 component_blueprint.ob,
'slotdef'):
79 component_blueprint.error(
80 _(
"improper slotdef= syntax: missing \":\" in \"%s\"") % value)
83 if value.startswith(
'%d:' % slot):
90 component_blueprint.error(
91 _(
"did not find slotdef= attribute for slot %d") % slot)
97 cptr = slotdef[slotdef.index(
':') + 1:]
100 component_blueprint.error(_(
"improper slotdef= syntax: "
101 "missing definition for slot %d") % slot)
104 return list(
strtok(cptr, SLOTDEF_ATTRIB_DELIMITERS))
107 for schematic
in netlist.schematics:
108 for component
in schematic.components:
114 component.pins_by_pinseq = {}
115 for pin
in component.pins:
117 value = pin.get_attribute(
'pinseq')
123 pin.error(_(
"non-numeric pinseq value: %s") % value)
125 if pinseq
in component.pins_by_pinseq:
126 if component.slotdef \
127 and pinseq - 1 >= 0 \
128 and pinseq - 1 < len(component.slotdef):
129 pin.error(_(
"duplicate pinseq \"%s\"") % pinseq)
131 pin.warn(_(
"duplicate pinseq \"%s\"") % pinseq)
133 component.pins_by_pinseq[pinseq] = pin
134 if component.slotdef
is not None \
135 and pinseq - 1 >= len(component.slotdef):
136 pin.warn(_(
"pin has pinseq=%d, but only %d pins are "
137 "covered by slot definition") % (
138 pinseq, len(component.slotdef)))
141 for pin
in component.pins:
142 pin.number = pin.get_attribute(
'pinnumber',
None)
145 if component.slotdef
is not None:
146 for i, pinnumber
in enumerate(component.slotdef):
148 pin = component.pins_by_pinseq[i + 1]
151 _(
"slot definition covers %d pins, "
152 "but there is no pin with pinseq=%d") % (
153 len(component.slotdef), i + 1))
155 pin.number = pinnumber
158 component.pins_by_number = {}
159 for pin
in component.pins:
160 if pin.number
is None:
161 pin.error(_(
"pinnumber missing"))
162 elif pin.number
in component.pins_by_number:
163 if component.composite_sources:
164 pin.warn(_(
"duplicate pinnumber \"%s\"") % pin.number)
166 pin.error(_(
"duplicate pinnumber \"%s\"") % pin.number)
168 component.pins_by_number[pin.number] = pin
Attribute parsing and lookup.
def get_slotdef
Get the active slot definition of a component.
def search_all
Search both attached and inherited attributes of a component for an attribute name and return matchin...
def strtok
Split a string into non-empty parts separated by a set of delimiters.