Skip to content

Commit

Permalink
allow for usage of inner_key when list is expected, used for any_of (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
djarecka committed Mar 12, 2024
1 parent 8d7c279 commit 7d1d66d
Showing 1 changed file with 8 additions and 1 deletion.
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

0 comments on commit 7d1d66d

Please sign in to comment.