Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def ohook(d):
if d.keys() == {"$jsii.byref"} or d.keys() == {"$jsii.byref", "$jsii.interfaces"}:
return ObjRef(ref=d["$jsii.byref"], interfaces=d.get("$jsii.interfaces"))
if d.keys() == {"$jsii.date"}:
return dateutil.parser.isoparse(d["$jsii.date"])
if d.keys() == {"$jsii.enum"}:
ref, member = d["$jsii.enum"].rsplit("/", 1)
return EnumRef(ref=ObjRef(ref=ref + "@"), member=member)
if d.keys() == {"$jsii.map"}:
return d["$jsii.map"]
return d
def ohook(d):
if d.keys() == {"$jsii.byref"} or d.keys() == {"$jsii.byref", "$jsii.interfaces"}:
return ObjRef(ref=d["$jsii.byref"], interfaces=d.get("$jsii.interfaces"))
if d.keys() == {"$jsii.date"}:
return dateutil.parser.isoparse(d["$jsii.date"])
if d.keys() == {"$jsii.enum"}:
ref, member = d["$jsii.enum"].rsplit("/", 1)
return EnumRef(ref=ObjRef(ref=ref + "@"), member=member)
if d.keys() == {"$jsii.map"}:
return d["$jsii.map"]
return d
CallbacksRequest,
_with_api_key("callbacks", self._serializer.unstructure_attrs_asdict),
)
self._serializer.register_unstructure_hook(
CompleteRequest,
_with_api_key("complete", self._serializer.unstructure_attrs_asdict),
)
self._serializer.register_unstructure_hook(
StatsRequest,
_with_api_key("stats", self._serializer.unstructure_attrs_asdict),
)
self._serializer.register_unstructure_hook(
Override, self._serializer.unstructure_attrs_asdict
)
self._serializer.register_unstructure_hook(ObjRef, _unstructure_ref)
self._serializer.register_structure_hook(ObjRef, _with_reference)
self._ctx_stack = contextlib.ExitStack()
self._serializer.register_unstructure_hook(
CallbacksRequest,
_with_api_key("callbacks", self._serializer.unstructure_attrs_asdict),
)
self._serializer.register_unstructure_hook(
CompleteRequest,
_with_api_key("complete", self._serializer.unstructure_attrs_asdict),
)
self._serializer.register_unstructure_hook(
StatsRequest,
_with_api_key("stats", self._serializer.unstructure_attrs_asdict),
)
self._serializer.register_unstructure_hook(
Override, self._serializer.unstructure_attrs_asdict
)
self._serializer.register_unstructure_hook(ObjRef, _unstructure_ref)
self._serializer.register_structure_hook(ObjRef, _with_reference)
self._ctx_stack = contextlib.ExitStack()
def _recursize_dereference(kernel, d):
if isinstance(d, dict):
return {k: _recursize_dereference(kernel, v) for k, v in d.items()}
elif isinstance(d, list):
return [_recursize_dereference(kernel, i) for i in d]
elif isinstance(d, ObjRef):
return _reference_map.resolve_reference(kernel, d)
elif isinstance(d, EnumRef):
return _recursize_dereference(kernel, d.ref)(d.member)
else:
return d