MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / unique_dict

Method unique_dict

tools/meta_codegen/framework/scheme.py:587–605  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

585 return result
586
587 def unique_dict(self) -> t.Dict[str, 'JsonObject']:
588 if type(self.val) is list and self.is_dict:
589 result = {}
590 for child in self.val:
591 if child.key is None:
592 raise ValueError("empty key in dict")
593
594 def __expand_child(child: 'JsonObject'):
595 if type(child.val) is list and child.is_dict: # dict case
596 return child
597 elif type(child.val) is list: # list case
598 return [__expand_child(c) for c in child.val]
599 else:
600 return child.val
601
602 result[child.key] = __expand_child(child)
603 return result
604 else:
605 raise ValueError("unique_dict() only works for dict")
606
607
608def json_object_pairs_hook(data: t.List[t.Tuple[str, object]]) -> JsonObject:

Callers 8

load_headerMethod · 0.80
load_from_raw_jsonMethod · 0.80
load_from_raw_jsonMethod · 0.80
load_from_raw_jsonMethod · 0.80
load_from_raw_jsonMethod · 0.80
load_from_raw_jsonMethod · 0.80
load_from_raw_jsonMethod · 0.80
load_from_raw_jsonMethod · 0.80

Calls 1

typeFunction · 0.50

Tested by

no test coverage detected