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

Method to_json

scratchattach/editor/inputs.py:88–110  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

86 return Input(_shadow, _value, _id, _obscurer, _obscurer_id=_obscurer_id)
87
88 def to_json(self) -> list:
89 data = [self.shadow.idx]
90
91 def add_pblock(pblock: prim.Prim | block.Block | None):
92 """
93 Adds a primitive or a block to the data in the right format
94 """
95 if pblock is None:
96 return
97
98 if isinstance(pblock, prim.Prim):
99 data.append(pblock.to_json())
100
101 elif isinstance(pblock, block.Block):
102 data.append(pblock.id)
103
104 else:
105 warnings.warn(f"Bad prim/block {pblock!r} of type {type(pblock)}")
106
107 add_pblock(self.value)
108 add_pblock(self.obscurer)
109
110 return data
111
112 def link_using_block(self):
113 """

Callers 1

add_pblockMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected