Skip to content

Commit 9b941bf

Browse files
committed
fix schema autodetect
1 parent aff1387 commit 9b941bf

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

pygeometa/core.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,9 @@ def import_metadata(schema: str, metadata: str) -> dict:
334334
:returns: MCF object
335335
"""
336336

337+
content = None
338+
error_message = None
339+
337340
if schema == 'autodetect':
338341
schemas = get_supported_schemas()
339342
else:
@@ -344,11 +347,17 @@ def import_metadata(schema: str, metadata: str) -> dict:
344347
schema_object = load_schema(s)
345348

346349
try:
347-
return schema_object.import_(metadata)
350+
content = schema_object.import_(metadata)
351+
break
348352
except NotImplementedError:
349-
raise RuntimeError(f'Import not supported for {s}')
353+
error_message = f'Import not supported for {s}'
350354
except Exception as err:
351-
raise RuntimeError(f'Import failed: {err}')
355+
error_message = f'Import failed: {err}'
356+
357+
if error_message is not None:
358+
LOGGER.warning(error_message)
359+
360+
return content
352361

353362

354363
def transform_metadata(input_schema: str, output_schema: str,

tests/run_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def test_get_supported_schemas(self):
236236
'Expected exact list of supported schemas')
237237

238238
schemas = get_supported_schemas(include_autodetect=True)
239-
self.assertEqual(len(schemas), 10,
239+
self.assertEqual(len(schemas), 11,
240240
'Expected specific number of supported schemas')
241241
self.assertIn('autodetect', schemas, 'Expected autodetect in list')
242242

0 commit comments

Comments
 (0)