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

Method id

scratchattach/editor/block.py:166–182  ·  view source on GitHub ↗

Work out the id of this block by searching through the sprite dictionary If one cannot be found, generate a new one and return that.

(self)

Source from the content-addressed store, hash-verified

164
165 @property
166 def id(self) -> str:
167 """
168 Work out the id of this block by searching through the sprite dictionary
169 If one cannot be found, generate a new one and return that.
170 """
171 if self._id:
172 return self._id
173 # warnings.warn(f"Using block IDs can cause consistency issues and is not recommended")
174 # This property is used when converting comments to JSON (we don't want random warning when exporting a project)
175 for _block_id, _block in self.sprite.blocks.items():
176 if _block is self:
177 self._id = _block_id
178 return self._id
179
180 # Let's just automatically assign ourselves an id
181 self.sprite.add_block(self)
182 return self._id
183
184 @id.setter
185 def id(self, value: str) -> None:

Callers

nothing calls this directly

Calls 1

add_blockMethod · 0.45

Tested by

no test coverage detected