Adjusted error messages and crossed comp generation.

- Also the name of the member for lib_name
This commit is contained in:
Salvador E. Tropea 2022-01-29 16:16:39 -03:00
parent 3b7b200d4f
commit 400d06f9b3
3 changed files with 19 additions and 11 deletions

View File

@ -757,7 +757,8 @@ class LibComponent(object):
res = comp.name.split(':')
comp.lib = None
if len(res) == 1:
# Apperas valid: https://docs.kicad.org/doxygen/classLIB__ID.html#a195467cfd12903226615d74540ec647a
# Appears valid: https://docs.kicad.org/doxygen/classLIB__ID.html#a195467cfd12903226615d74540ec647a
# Note: seems to be a locally edited component
comp.name = res[0]
comp.lib = ''
elif len(res) == 2:
@ -765,7 +766,7 @@ class LibComponent(object):
comp.lib = res[0]
else:
if parent is None:
logger.warning(W_NOLIB + "Component `{}` doesn't specify its library".format(comp.name))
logger.warning(W_NOLIB + "Component `{}` with more than one `:`".format(comp.name))
comp.units = []
comp.pins = []
comp.all_pins = []
@ -883,7 +884,7 @@ class LibComponent(object):
if cross:
# Fill the cross_box of our sub/units
s.assign_crosses()
if s.lib:
if s.units:
# Use an alternative name
lib_id = CROSSED_LIB+':'+s.name
sdata = [lib_id]
@ -930,6 +931,7 @@ class SchematicComponentV6(SchematicComponent):
self.unit = 1
self.unit_specified = False
self.ref = None
self.local_name = None
def set_ref(self, ref):
self.ref = ref
@ -977,17 +979,17 @@ class SchematicComponentV6(SchematicComponent):
res = comp.name.split(':')
comp.lib = None
if len(res) == 1:
comp.name = res[1]
comp.name = res[0]
comp.lib = ''
elif len(res) == 2:
comp.name = res[1]
comp.lib = res[0]
else:
logger.warning(W_NOLIB + "Component `{}` doesn't specify its library".format(comp.name))
logger.warning(W_NOLIB + "Component `{}` with more than one `:`".format(comp.name))
lib_id_found = True
elif i_type == 'lib_name':
# Symbol defined in schematic
comp.schlib_name = _check_str(i, 1, name + ' lib_name')
comp.local_name = _check_str(i, 1, name + ' lib_name')
elif i_type == 'at':
# 2 The position
if len(i) > 3:
@ -1039,9 +1041,9 @@ class SchematicComponentV6(SchematicComponent):
def write(self, cross=False):
lib_id = self.lib_id
is_crossed = not(self.fitted or not self.included)
if cross and self.lib and is_crossed:
if cross and (self.lib or self.local_name) and is_crossed:
# Use an alternative name
lib_id = CROSSED_LIB+':'+self.name
lib_id = CROSSED_LIB+':'+(self.local_name if self.local_name else self.name)
data = [_symbol('lib_id', [lib_id]),
_symbol('at', [self.x, self.y, self.ang])]
if self.unit_specified:

View File

@ -61,7 +61,7 @@
)
)
(symbol (lib_id "Resistor") (at 53.34 43.18 0) (unit 1)
(symbol (lib_id "A:B:Resistor") (at 53.34 43.18 0) (unit 1)
(in_bom yes) (on_board yes)
(uuid 00000000-0000-0000-0000-00005f43d144)
(property "Reference" "R1" (id 0) (at 55.118 42.0116 0)

View File

@ -147,7 +147,10 @@ def test_sch_missing_1(test_dir):
ctx.run()
o_name = os.path.join(NI_DIR, prj+context.KICAD_SCH_EXT)
ctx.expect_out_file(o_name)
ctx.search_err("Component .?Resistor.? doesn't specify its library")
if context.ki5():
ctx.search_err("Component .?Resistor.? doesn't specify its library")
else:
ctx.search_err("Component .?A:B:Resistor.? with more than one .?:.?")
ctx.search_err("Missing component .?l1:FooBar.?")
ctx.search_err("Missing component(.*)Resistor", invert=context.ki5())
ctx.search_err("Missing doc-lib entry for l1:C", invert=(not context.ki5()))
@ -163,7 +166,10 @@ def test_sch_missing_filtered(test_dir):
ctx.run()
o_name = os.path.join(NI_DIR, prj+context.KICAD_SCH_EXT)
ctx.expect_out_file(o_name)
ctx.search_err("Component .?Resistor.? doesn't specify its library")
if context.ki5():
ctx.search_err("Component .?Resistor.? doesn't specify its library")
else:
ctx.search_err("Component .?A:B:Resistor.? with more than one .?:.?")
ctx.search_err("Missing component .?l1:FooBar.?", invert=True)
ctx.search_err("Missing component(.*)Resistor", invert=context.ki5())
ctx.search_err("Missing doc-lib entry for l1:C", invert=(not context.ki5()))