Skip to content

Commit

Permalink
[Fixed] Problems with some malformed references when importing a CSV
Browse files Browse the repository at this point in the history
  • Loading branch information
set-soft committed Jul 16, 2024
1 parent dead00d commit 244617d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -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 <salvador@inti.gob.ar> Tue, 16 Jul 2024 08:56:03 -0300

Expand Down
1 change: 1 addition & 0 deletions kicost/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 7 additions & 3 deletions kicost/edas/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand All @@ -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))]

Expand All @@ -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
Expand Down

0 comments on commit 244617d

Please sign in to comment.