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

Method export

scratchattach/editor/sprite.py:561–577  ·  view source on GitHub ↗
(self, fp: Optional[str] = None, *, export_as_zip: bool = True)

Source from the content-addressed store, hash-verified

559 return None
560
561 def export(self, fp: Optional[str] = None, *, export_as_zip: bool = True):
562 if fp is None:
563 fp = commons.sanitize_fn(f"{self.name}.sprite3")
564
565 data = self.to_json()
566
567 if export_as_zip:
568 with ZipFile(fp, "w") as archive:
569 for _asset in self.assets:
570 asset_file = _asset.asset_file
571 if asset_file.filename not in archive.namelist():
572 archive.writestr(asset_file.filename, asset_file.data)
573
574 archive.writestr("sprite.json", json.dumps(data))
575 else:
576 with open(fp, "w") as json_file:
577 json.dump(data, json_file)
578
579 @property
580 def all_ids(self):

Callers 1

test_projectFunction · 0.45

Calls 1

to_jsonMethod · 0.95

Tested by 1

test_projectFunction · 0.36