From 41c66b1ab498e3112005a2d83b5411383963d7b8 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Sun, 30 Aug 2020 11:54:34 -0300 Subject: [PATCH] Added support for '~' as empty value. --- kibot/bom/bom.py | 9 ++++++++- kibot/bom/units.py | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/kibot/bom/bom.py b/kibot/bom/bom.py index 1a4f1f14..4f3f76c5 100644 --- a/kibot/bom/bom.py +++ b/kibot/bom/bom.py @@ -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): diff --git a/kibot/bom/units.py b/kibot/bom/units.py index 125f1c71..f4d45617 100644 --- a/kibot/bom/units.py +++ b/kibot/bom/units.py @@ -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: