MCPcopy Create free account
hub / github.com/TimMcCool/scratchattach / from_json

Method from_json

scratchattach/editor/prim.py:116–134  ·  view source on GitHub ↗
(data: list)

Source from the content-addressed store, hash-verified

114
115 @staticmethod
116 def from_json(data: list):
117 assert isinstance(data, list)
118
119 _type_idx = data[0]
120 _prim_type = PrimTypes.find(_type_idx, "code")
121
122 _value, _name, _value_id, _x, _y = (None,) * 5
123 if _prim_type.attrs == BASIC_ATTRS:
124 assert len(data) == 2
125 _value = data[1]
126
127 elif _prim_type.attrs == VLB_ATTRS:
128 assert len(data) in (3, 5)
129 _name, _value_id = data[1:3]
130
131 if len(data) == 5:
132 _x, _y = data[3:]
133
134 return Prim(_prim_type, _value, _name, _value_id, _x, _y)
135
136 def to_json(self) -> list:
137 if self.type.attrs == BASIC_ATTRS:

Callers

nothing calls this directly

Calls 2

PrimClass · 0.85
findMethod · 0.45

Tested by

no test coverage detected