Added support for '~' as empty value.

This commit is contained in:
Salvador E. Tropea 2020-08-30 11:54:34 -03:00
parent 4ed499531b
commit 41c66b1ab4
2 changed files with 13 additions and 2 deletions

View File

@ -26,8 +26,15 @@ RLC_PREFIX = {'R': 1, 'L': 1, 'C': 1, 'RV': 1, 'RN': 1, 'RT': 1}
def compare_value(c1, c2, cfg):
""" Compare the value of two components """
c1_value = c1.value.strip().lower()
c2_value = c2.value.strip().lower()
# '~' is the same as empty for KiCad
if c1_value == '~':
c1_value = ''
if c2_value == '~':
c2_value = ''
# Simple string comparison
if c1.value.lower() == c2.value.lower():
if c1_value == c2_value:
return True
# Otherwise, perform a more complicated value comparison
if compare_values(c1, c2):

View File

@ -103,8 +103,12 @@ def comp_match(component, ref_prefix):
e.g. comp_match('10R2') returns (10, R)
e.g. comp_match('3.3mOhm') returns (0.0033, R)
"""
original = component
# Remove useless spaces
component = component.strip()
# ~ is the same as empty for KiCad
if component == '~':
component = ''
# Convert the decimal point from the current locale to a '.'
global decimal_point
if decimal_point is None: