Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions processing/load_languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ def get_acron_issueid_fname_without_extension(file_path):
"""
_file_path = os.path.normpath(file_path.replace('\\', '/')).lower()
try:
file_id = FILE_REGEX.search(_file_path).group()
match = FILE_REGEX.search(_file_path)
if not match:
logger.error(
u'Fail to parse file_path %s: no regex match', file_path)
return
file_id = match.group()
file_id, ext = os.path.splitext(file_id)
folders = file_id.split('/')
if not ext == '.xml':
Expand All @@ -102,11 +107,11 @@ def get_acron_issueid_fname_without_extension(file_path):
folders = folders[-3:]
if len(folders) != 3:
logger.error(
u'Fail to parse file_path %s for %s', (file_path, file_id))
u'Fail to parse file_path %s for %s', file_path, file_id)
return
except:
except Exception:
logger.error(
u'Fail to parse file_path %s for %s', (file_path, file_id))
u'Fail to parse file_path %s', file_path)
return
return folders

Expand Down
9 changes: 9 additions & 0 deletions tests/test_load_languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ def test_get_acron_issueid_fname_without_extension(self):
['mioc', 'v82s3', 'vol82(fsup3)_ii']
)

def test_get_acron_issueid_fname_without_extension_no_match(self):
get_file_id = load_languages.get_acron_issueid_fname_without_extension
self.assertIsNone(
get_file_id('./argos/aceeed/n21/2545-8299-ACEEED-21-137')
)
self.assertIsNone(
get_file_id('some/random/path/without/valid/extension')
)

@patch.object(
load_languages.StaticCatalog, "__init__", mock_static_catalog_init_method
)
Expand Down