diff --git a/debian/changelog b/debian/changelog index 1cca68c7..bc490631 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ kicost (1.1.20-1) UNRELEASED; urgency=medium * Fixed Nexar problems when the API reports errors * Fixed Element14 too fast queries + * Fixed problems with some malformed references when importing a CSV -- Salvador Eduardo Tropea Tue, 16 Jul 2024 08:56:03 -0300 diff --git a/kicost/HISTORY.rst b/kicost/HISTORY.rst index 9690b0e7..aa744fb3 100644 --- a/kicost/HISTORY.rst +++ b/kicost/HISTORY.rst @@ -7,6 +7,7 @@ History _____________________ * Fixed Nexar problems when the API reports errors * Fixed Element14 too fast queries +* Fixed problems with some malformed references when importing a CSV 1.1.19 (2023-05-06) diff --git a/kicost/edas/tools.py b/kicost/edas/tools.py index b52a5cc7..76adf323 100644 --- a/kicost/edas/tools.py +++ b/kicost/edas/tools.py @@ -762,7 +762,7 @@ def split_refs(text): # ref = re.sub('^\-', '', ref) # Starting "-". # ref = re.sub('\-$', 'n', ref) # Finishing "-". if re.search(r'^\w+\d', ref): - if re.search('-', ref): + if re.search('-', ref) and re.search(r'^\D+', ref): designator_name = re.findall(r'^\D+', ref)[0] split_nums = re.split('-', ref) designator_name += ''.join(re.findall(r'^d*\W', split_nums[0])) @@ -774,7 +774,11 @@ def split_refs(text): base_split_nums = ''.join(re.findall(r'^\d+\D', split_nums[0])) split_nums = [''.join(re.findall(r'\D*(\d+)$', n)) for n in split_nums] - split = list(range(int(split_nums[0]), int(split_nums[1])+1)) + try: + split = list(range(int(split_nums[0]), int(split_nums[1])+1)) + except ValueError: + refs.append(ref.strip()) + continue # split = [designator_name+str(split[i]) for i in range(len(split)) ] split = [designator_name + base_split_nums+str(split[i]) for i in range(len(split))] @@ -784,7 +788,7 @@ def split_refs(text): split_nums = [re.sub('^'+designator_name, '', i) for i in re.split(r'[/\\]', ref)] refs += [designator_name+i for i in split_nums] else: - refs += [ref.strip()] + refs.append(ref.strip()) else: # The designator name is not for a group of components and # "\", "/" or "-" is part of the name. This characters have