some fixes and improvements
This commit is contained in:
@@ -24,10 +24,22 @@ def _as_dict(value: Any, context: str) -> dict[str, Any]:
|
||||
return value
|
||||
|
||||
|
||||
def _read_str(payload: dict[str, Any], key: str, default: str) -> str:
|
||||
"""Return payload string, treating an explicit JSON `null` as missing.
|
||||
|
||||
`payload.get(key, default)` returns `None` when the key exists with value
|
||||
`null`, which is then coerced into the literal string `"None"` by `str()`.
|
||||
"""
|
||||
value = payload.get(key, default)
|
||||
if value is None:
|
||||
return default
|
||||
return str(value)
|
||||
|
||||
|
||||
def _load_preprocess_asset(payload: dict[str, Any], target: PreprocessAssetModel) -> None:
|
||||
"""Load preprocess asset fields into target model."""
|
||||
target.set_name = str(payload.get("set_name", target.set_name))
|
||||
target.bundle_path = str(payload.get("bundle_path", target.bundle_path))
|
||||
target.set_name = _read_str(payload, "set_name", target.set_name)
|
||||
target.bundle_path = _read_str(payload, "bundle_path", target.bundle_path)
|
||||
|
||||
|
||||
def _load_string_list(payload: dict[str, Any], key: str, context: str) -> list[str]:
|
||||
|
||||
Reference in New Issue
Block a user