fixed asset class key mixup

Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
Lorenz Herzberger 2023-01-10 10:14:23 +01:00
parent 69e6cf7df0
commit 61c35bd0fb
No known key found for this signature in database
GPG Key ID: FA5EE906EB55316A

View File

@ -4,20 +4,21 @@
# Code is Apache-2.0 and docs are CC-BY-4.0
from __future__ import annotations
import json
from dataclasses import dataclass
@dataclass
class Asset:
key: str = ""
data: str = ""
@staticmethod
def from_dict(asset_dict: dict) -> Asset:
return Asset(asset_dict["data"]) if "data" in asset_dict.keys() else Asset(asset_dict["id"])
key = "data" if "data" in asset_dict.keys() else "id"
data = asset_dict[key]
return Asset(key, data)
def to_dict(self) -> dict:
return {"data": self.data}
return {self.key: self.data}
@staticmethod
def from_list_dict(asset_dict_list: list[dict]) -> list[Asset]: