Skip to content

Commit 22f6c6e

Browse files
committed
Support for v3 of schema in templates added. Warning that support for v2 will be removed.
1 parent 11d391e commit 22f6c6e

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

csv2bufr/templates/__init__.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
THISDIR = os.path.dirname(os.path.realpath(__file__))
3030
LOGGER = logging.getLogger(__name__)
3131
SCHEMA = f"{THISDIR}{os.sep}resources{os.sep}schema"
32+
SCHEMA_VERSIONS = ['csv2bufr-template-v2.json', 'csv2bufr-template-v3.json']
3233
TEMPLATE_DIRS = [] # [Path("./")]
3334

3435
_SUCCESS_ = True
@@ -178,15 +179,17 @@ def index_templates() -> bool:
178179
# check if valid mapping file
179180
with template.open() as fh:
180181
tmpl = json.load(fh)
181-
if 'csv2bufr-template-v3.json' not in tmpl.get("conformsTo",[]): # noqa
182-
if 'csv2bufr-template-v2.json' in tmpl.get("conformsTo",[]): # noqa
183-
LOGGER.warning("Deprecated 'csv2bufr-template-v2.json' found in " + # noqa
184-
f"conformsTo for file {template}") # noqa
185-
LOGGER.warning("Support for 'csv2bufr-template-v2.json' will be removed in a future release") # noqa
186-
else:
187-
LOGGER.warning("'csv2bufr-template-v3.json' not found in " + # noqa
188-
f"conformsTo for file {template}, skipping") # noqa
189-
continue
182+
valid_schema = False
183+
for sc in SCHEMA_VERSIONS:
184+
if sc in tmpl.get("conformsTo",[]):
185+
valid_schema = True
186+
break
187+
if not valid_schema:
188+
LOGGER.warning(
189+
"No valid schema not found in " + # noqa
190+
f"conformsTo for file {template}, skipping") # noqa
191+
continue
192+
190193
if validate_template(tmpl) == _SUCCESS_:
191194
# get label if exists else set to empty string
192195
fname = str(template)

0 commit comments

Comments
 (0)