Skip to content

Commit

Permalink
strip_schema_keys
Browse files Browse the repository at this point in the history
  • Loading branch information
eagmon committed Jul 16, 2024
1 parent 6075161 commit 8bcba10
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions bigraph_schema/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,18 @@ def divide_any(schema, state, values, core):
def is_schema_key(key):
return isinstance(key, str) and key.startswith('_')

def strip_schema_keys(state):
"""remove schema keys from a state dictionary, including nested dictionaries"""
if isinstance(state, dict):
output = {}
for key, value in state.items():
if not is_schema_key(key):
output[key] = strip_schema_keys(value)
else:
output = state
return output



def type_parameter_key(schema, key):
return key.strip('_') not in schema.get('_type_parameters', []) and key.startswith('_')
Expand Down

0 comments on commit 8bcba10

Please sign in to comment.