Skip to content

Commit

Permalink
Catch ValueError exception during nb and tilt formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasfrosio committed Sep 20, 2019
1 parent 7008c73 commit 343a36d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,10 @@ def _clean_raw_files(self, raw_files):
raw_files_cleaned, raw_files_cleaned_nb, raw_files_cleaned_tilt = [], [], []
for file in raw_files:
filename_split = file.split('/')[-1].split('_')
stack_nb = int(''.join(i for i in filename_split[self.inputs.ba_set_field_nb] if i.isdigit()))
try:
stack_nb = int(''.join(i for i in filename_split[self.inputs.ba_set_field_nb] if i.isdigit()))
except IndexError or ValueError as err:
raise IndexError(f'Clean files (nb): {err}')

# first check that the stack was not processed already
if stack_nb in stack2remove:
Expand All @@ -1201,8 +1204,8 @@ def _clean_raw_files(self, raw_files):
file_tilt = filename_split[self.inputs.ba_set_field_tilt].replace(
f'.{self.extension}', '').replace('[', '').replace(']', '')
raw_files_cleaned_tilt.append(float(file_tilt))
except IndexError as err:
raise IndexError(f'Clean raw files: {err}')
except IndexError or ValueError as err:
raise IndexError(f'Clean files (tilt): {err}')

return raw_files_cleaned, raw_files_cleaned_nb, raw_files_cleaned_tilt

Expand Down

0 comments on commit 343a36d

Please sign in to comment.