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

Parse fully qualified comp instance name in JSON loaders #178

Merged
merged 4 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ RLock
Roboto
rollup
rpaetz
rsplit
rst
rtd
rtf
Expand Down
8 changes: 4 additions & 4 deletions src/fprime_gds/common/loaders/ch_json_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ def construct_template_from_dict(self, channel_dict: dict) -> ChTemplate:
try:
ch_id = channel_dict[self.ID]
# The below assignment also raises a ValueError if the name does not contain a '.'
component_name, channel_name = channel_dict[self.NAME].split(".")
if not component_name or not channel_name:
qualified_component_name, channel_name = channel_dict[self.NAME].rsplit('.', 1)
if not qualified_component_name or not channel_name:
raise ValueError()

type_obj = self.parse_type(channel_dict[self.TYPE])
except ValueError as e:
raise GdsDictionaryParsingException(
f"Channel dictionary entry malformed, expected name of the form '<COMP_NAME>.<CH_NAME>' in : {str(channel_dict)}"
f"Channel dictionary entry malformed, expected name of the form '<QUAL_COMP_NAME>.<CH_NAME>' in : {str(channel_dict)}"
)
except KeyError as e:
raise GdsDictionaryParsingException(
Expand All @@ -94,7 +94,7 @@ def construct_template_from_dict(self, channel_dict: dict) -> ChTemplate:
return ChTemplate(
ch_id,
channel_name,
component_name,
qualified_component_name,
type_obj,
ch_fmt_str=format_str,
ch_desc=channel_dict.get(self.DESC),
Expand Down
6 changes: 3 additions & 3 deletions src/fprime_gds/common/loaders/cmd_json_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ def construct_dicts(self, _):

def construct_template_from_dict(self, cmd_dict: dict) -> CmdTemplate:
try:
cmd_comp, cmd_mnemonic = cmd_dict[self.NAME].split(".")
qualified_component_name, cmd_mnemonic = cmd_dict[self.NAME].rsplit('.', 1)
cmd_opcode = cmd_dict[self.OPCODE]
cmd_desc = cmd_dict.get(self.DESC)
except ValueError as e:
raise GdsDictionaryParsingException(
f"Command dictionary entry malformed, expected name of the form '<COMP_NAME>.<CMD_NAME>' in : {str(cmd_dict)}"
f"Command dictionary entry malformed, expected name of the form '<QUAL_COMP_NAME>.<CMD_NAME>' in : {str(cmd_dict)}"
)
except KeyError as e:
raise GdsDictionaryParsingException(
Expand All @@ -82,4 +82,4 @@ def construct_template_from_dict(self, cmd_dict: dict) -> CmdTemplate:
param_type,
)
)
return CmdTemplate(cmd_opcode, cmd_mnemonic, cmd_comp, cmd_args, cmd_desc)
return CmdTemplate(cmd_opcode, cmd_mnemonic, qualified_component_name, cmd_args, cmd_desc)
6 changes: 3 additions & 3 deletions src/fprime_gds/common/loaders/event_json_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ def construct_dicts(self, _):

def construct_template_from_dict(self, event_dict: dict):
try:
event_comp, event_name = event_dict[self.NAME].split(".")
qualified_component_name, event_name = event_dict[self.NAME].rsplit('.', 1)
event_id = event_dict[self.ID]
event_severity = EventSeverity[event_dict[self.SEVERITY]]
except ValueError as e:
raise GdsDictionaryParsingException(
f"Event dictionary entry malformed, expected name of the form '<COMP_NAME>.<EVENT_NAME>' in : {str(event_dict)}"
f"Event dictionary entry malformed, expected name of the form '<QUAL_COMP_NAME>.<EVENT_NAME>' in : {str(event_dict)}"
)
except KeyError as e:
raise GdsDictionaryParsingException(
Expand Down Expand Up @@ -100,7 +100,7 @@ def construct_template_from_dict(self, event_dict: dict):
return EventTemplate(
event_id,
event_name,
event_comp,
qualified_component_name,
event_args,
event_severity,
event_fmt_str,
Expand Down
Loading