Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the reading of the deprecated component format #530

Merged
merged 1 commit into from
Dec 13, 2023
Merged
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
59 changes: 0 additions & 59 deletions python/podio_gen/podio_config_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,69 +327,10 @@ def _handle_extracode(definition):
"""Handle the extra code definition. Currently simply returning a copy"""
return copy.deepcopy(definition)

@staticmethod
def _read_component_old_definition(definition):
"""Read the component and put it into a similar structure as the datatypes, i.e.
a dict with a 'Members' and an 'ExtraCode' field for easier handling
afterwards
"""
warning_text = """

You are using the deprecated old style of defining components:

components:
ExampleComponent:
x : int
ExtraCode:
declaration: "// some code here"

This option will be removed with version 1.0.
Switch to the new style of defining components (consistent with datatypes definitions):

components:
ExampleComponent:
Members:
- int x // an optional description here
ExtraCode:
declaration: "// some code here"

"""
warnings.warn(warning_text, FutureWarning, stacklevel=3)
component = {'Members': []}
for name, klass in definition.items():
if name == 'ExtraCode':
component['ExtraCode'] = klass
else:
valid_type = MemberParser.type_re.match(klass)
valid_name = MemberParser.name_re.match(name)
c_style_array = re.search(r'\[.*\]', klass)
if valid_type and valid_name and not c_style_array:
array_match = MemberParser.array_re.match(klass)
if array_match:
component['Members'].append(MemberVariable(name=name, array_type=array_match.group(1),
array_size=array_match.group(2)))
else:
component['Members'].append(MemberVariable(name=name, type=klass))
else:
raise DefinitionError(f"'{name}: {klass}' is not a valid member definition")

return component

@classmethod
def _read_component(cls, definition):
"""Read the component and put it into an easily digestible format.

Currently handles two versions of syntax:
- One that is different than the one used for datatypes, deprecated and
planned for removal with 1.0
- A consistent one with the syntax for datatypes, with slightly less
capabilities
"""
# Very basic check here to differentiate between old and new style component
# definitions
if "Members" not in definition:
return cls._read_component_old_definition(definition)

component = {}
for name, category in definition.items():
if name == 'Members':
Expand Down