1
0
Fork 0

only use subkeys when they are an object

This commit is contained in:
Sean Sube 2024-03-02 14:12:02 -06:00
parent 415405c2b2
commit c95fd5f257
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
1 changed files with 13 additions and 4 deletions

View File

@ -476,10 +476,10 @@ def get_request_params(
device, params, size = pipeline_from_json(server, data, default_pipeline) device, params, size = pipeline_from_json(server, data, default_pipeline)
border = build_border(data.get("border", data)) border = build_border(get_dict_or_self(data, "border"))
upscale = build_upscale(data.get("upscale", data)) upscale = build_upscale(get_dict_or_self(data, "upscale"))
highres = build_highres(data.get("highres", data)) highres = build_highres(get_dict_or_self(data, "highres"))
experimental = build_experimental(data.get("experimental", data)) experimental = build_experimental(get_dict_or_self(data, "experimental"))
return RequestParams( return RequestParams(
device, device,
@ -490,3 +490,12 @@ def get_request_params(
highres=highres, highres=highres,
experimental=experimental, experimental=experimental,
) )
def get_dict_or_self(dict: Dict[str, Any], key: str) -> Any:
if key in dict:
value = dict[key]
if isinstance(value, dict):
return value
return dict