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

allow for usage of inner_key when list is expected #137

Merged
merged 1 commit into from
Mar 12, 2024
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
9 changes: 8 additions & 1 deletion schemasheets/schemamaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,14 @@ def add_row(self, row: Dict[str, Any], table_config: TableConfig):
logging.warning(f'Overwriting value for {k}, was {curr_val}, now {v}')
raise ValueError(f'Cannot reset value for {k}, was {curr_val}, now {v}')
if cc.settings.inner_key:
getattr(actual_element, cc.maps_to)[cc.settings.inner_key] = v
if isinstance(getattr(actual_element, cc.maps_to), list):
if '|' in v:
vs = v.split('|')
else:
vs = [v]
setattr(actual_element, cc.maps_to, [{cc.settings.inner_key: v} for v in vs])
else:
getattr(actual_element, cc.maps_to)[cc.settings.inner_key] = v
else:
setattr(actual_element, cc.maps_to, v)
elif cc.is_element_type:
Expand Down
Loading