From 1dfa01112c2157395791e3ccd32e5c71341881f9 Mon Sep 17 00:00:00 2001 From: IanCa Date: Tue, 26 Mar 2024 17:41:57 -0500 Subject: [PATCH] Fix source_format when using a mix of xml/mediawiki sources --- hed/schema/schema_io/base2schema.py | 2 ++ tests/schema/test_schema_compare.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/hed/schema/schema_io/base2schema.py b/hed/schema/schema_io/base2schema.py index a1074e18..75847446 100644 --- a/hed/schema/schema_io/base2schema.py +++ b/hed/schema/schema_io/base2schema.py @@ -104,6 +104,7 @@ def _load(self): if not self.appending_to_schema and self._schema.with_standard and not self._schema.merged: from hed.schema.hed_schema_io import load_schema_version saved_attr = self._schema.header_attributes + saved_format = self._schema.source_format try: base_version = load_schema_version(self._schema.with_standard) except HedFileError as e: @@ -115,6 +116,7 @@ def _load(self): self._schema.filename = self.filename self._schema.name = self.name # Manually set name here as we don't want to pass it to load_schema_version self._schema.header_attributes = saved_attr + self._schema.source_format = saved_format self._loading_merged = False self._parse_data() diff --git a/tests/schema/test_schema_compare.py b/tests/schema/test_schema_compare.py index 31302c66..f3ceb273 100644 --- a/tests/schema/test_schema_compare.py +++ b/tests/schema/test_schema_compare.py @@ -57,7 +57,9 @@ def test_compare_schemas(self): def test_compare_and_summarize_schemas_test(self): schema1 = load_schema(os.path.join(self.base_data, "schema_compare.mediawiki"), name="Schema1") + self.assertEqual(schema1.source_format, ".mediawiki") schema2 = load_schema(os.path.join(self.base_data, "schema_compare2.mediawiki"), name="Schema2") + self.assertEqual(schema2.source_format, ".mediawiki") result = gather_schema_changes(schema1, schema2) self.assertEqual(sum(len(x) for x in result.values()), 30)