(origin: dict, schema: dict)
| 94 | |
| 95 | |
| 96 | def dict_shorten(origin: dict, schema: dict): |
| 97 | for key, value in list(origin.items()): |
| 98 | if key not in schema: |
| 99 | del origin[key] |
| 100 | else: |
| 101 | if isinstance(value, dict): |
| 102 | dict_shorten(value, schema[key]) # schema[key] should be a dict |
| 103 | elif isinstance(value, list): |
| 104 | if value: |
| 105 | if isinstance(value[0], dict): |
| 106 | for item in value: |
| 107 | dict_shorten(item, schema[key][0]) # schema[key] should be a list with only one dict element |
| 108 | return origin |
| 109 | |
| 110 | def observation_shorten(schema_root, response_dict, category, tool_name, api_name, strip_method): |
| 111 | print(random.random()) |
no outgoing calls
no test coverage detected