Skip to content
Snippets Groups Projects
Verified Commit 3a8bed9b authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Leave out optional attributes

Docs say there are defaults, but there aren't…
parent a03e7505
No related branches found
No related tags found
No related merge requests found
...@@ -8,34 +8,41 @@ import json ...@@ -8,34 +8,41 @@ import json
class IconifyOptional: class IconifyOptional:
left: int = 0 left: Optional[int] = None
top: int = 0 top: Optional[int] = None
width: int = 16 width: Optional[int] = None
height: int = 16 height: Optional[int] = None
rotate: int = 0 rotate: Optional[int] = None
h_flip: bool = False h_flip: Optional[bool] = None
v_flip: bool = False v_flip: Optional[bool] = None
def _as_dict_optional(self) -> dict: def _as_dict_optional(self) -> dict:
return { res = {}
"left": self.left, if self.left is not None:
"top": self.top, res["left"] = self.left
"width": self.width, if self.top is not None:
"height": self.height, res["top"] = self.top
"rotate": self.rotate, if self.width is not None:
"hFlip": self.h_flip, res["width"] = self.width
"vFlip": self.v_flip, if self.height is not None:
} res["height"] = self.height
if self.rotate is not None:
res["rotate"] = self.rotate
if self.h_flip is not None:
res["hFlip"] = self.h_flip
if self.v_flip is not None:
res["vFlip"] = self.v_flip
return res
def _from_dict_optional(self, src: dict) -> None: def _from_dict_optional(self, src: dict) -> None:
self.left = src.get("left", None) or self.left self.left = src.get("left", None)
self.top = src.get("top", None) or self.top self.top = src.get("top", None)
self.width = src.get("width", None) or self.width self.width = src.get("width", None)
self.height = src.get("height", None) or self.height self.height = src.get("height", None)
self.rotate = src.get("rotate", None) or self.rotate self.rotate = src.get("rotate", None)
self.h_flip = src.get("hFlip", None) or self.h_flip self.h_flip = src.get("hFlip", None)
self.v_flip = src.get("vFlip", None) or self.v_flip self.v_flip = src.get("vFlip", None)
class IconifyIcon(IconifyOptional): class IconifyIcon(IconifyOptional):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment