From 4b7c3c7b317cf4793f5ba5ad0d96102f103b66a3 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 8 Oct 2019 15:57:35 -0700 Subject: dict wrapper for entity_from_json() --- python/fatcat_tools/transforms/entities.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'python/fatcat_tools/transforms/entities.py') diff --git a/python/fatcat_tools/transforms/entities.py b/python/fatcat_tools/transforms/entities.py index 8e5de286..ae666413 100644 --- a/python/fatcat_tools/transforms/entities.py +++ b/python/fatcat_tools/transforms/entities.py @@ -1,5 +1,5 @@ - +import json import collections from fatcat_openapi_client import ApiClient @@ -21,7 +21,7 @@ def entity_from_json(json_str, entity_type, api_client=None): """ Hack to take advantage of the code-generated deserialization code - See not on `entity_to_dict()` about api_client argument. + See note on `entity_to_dict()` about api_client argument. """ if not api_client: api_client = ApiClient() @@ -29,3 +29,7 @@ def entity_from_json(json_str, entity_type, api_client=None): thing.data = json_str return api_client.deserialize(thing, entity_type) +def entity_from_dict(obj, entity_type, api_client=None): + json_str = json.dumps(obj) + return entity_from_json(json_str, entity_type, api_client=api_client) + -- cgit v1.2.3