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

Method data

scratchattach/editor/asset.py:22–35  ·  view source on GitHub ↗

Return the contents of the asset file, as bytes

(self)

Source from the content-addressed store, hash-verified

20
21 @property
22 def data(self) -> bytes:
23 """
24 Return the contents of the asset file, as bytes
25 """
26 if self._data is None:
27 # Download and cache
28 rq = requests.get(f"https://assets.scratch.mit.edu/internalapi/asset/{self.filename}/get/")
29 # print(f"Downloaded {url}")
30 if rq.status_code != 200:
31 raise ValueError(f"Can't download asset {self.filename}\nIs not uploaded to scratch! Response: {rq.text}")
32
33 self._data = rq.content
34
35 return self._data
36
37 @data.setter
38 def data(self, data: bytes):

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected