From dd598671166eb72a880428dc9300c302ecfe2dfe Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Wed, 21 Jun 2023 10:01:04 +0100 Subject: [PATCH] [UR] Address review feedback --- scripts/core/CONTRIB.rst | 7 ++++--- scripts/parse_specs.py | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/core/CONTRIB.rst b/scripts/core/CONTRIB.rst index 16a48c57d2..f40307e34e 100644 --- a/scripts/core/CONTRIB.rst +++ b/scripts/core/CONTRIB.rst @@ -219,9 +219,10 @@ implement your experimental feature. Experimental features *must* not make any changes to the core YaML files and *must* be described entirely in their own YaML file. Sometimes, however experimental feature require extending enumerations of the core specification. -If this is necessary should set the `extend` field to true and list the required -enumerations to support the experimental feature. These additional enumerations -will updated the specification with the appropriate values. +If this is necessary, create a new enum with the ``extend`` field set to true +and list the required enumerations to support the experimental feature. These +additional enumerations will updated the specification with the appropriate +values. Naming Convention diff --git a/scripts/parse_specs.py b/scripts/parse_specs.py index cb3c8ddd2f..23080c98c3 100644 --- a/scripts/parse_specs.py +++ b/scripts/parse_specs.py @@ -813,7 +813,13 @@ def refresh_enum_meta(obj, header, meta): def handle_enum_extensions(d, specs, header, meta): - matching_enum = [obj for s in specs for obj in s['objects'] if obj['type'] == 'enum' and d['name'] == obj['name']][0] + matching_enums = [obj for s in specs for obj in s['objects'] if obj['type'] == 'enum' and d['name'] == obj['name'] and not obj.get('extend')] + if len(matching_enums) != 1: + raise Exception(f""" +Could not find matching enum to extend {d['name']}. +You should check the ordinal value of the headers to ensure that the enum +is defined before you extend it.""") + matching_enum = matching_enums[0] matching_enum['etors'].extend(d['etors']) ## Refresh metadata