Skip to content

Commit

Permalink
safe_dump
Browse files Browse the repository at this point in the history
  • Loading branch information
bomzheg committed Mar 2, 2025
1 parent 0fcb404 commit b926e88
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions shvatka/core/services/scenario/scn_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ def unpack_scn(zip_file: ZipPath) -> scn.ParsedZip:

def pack_scn(game: scn.RawGameScenario) -> BinaryIO:
output = BytesIO()
data = yaml.safe_dump(game.scn, allow_unicode=True, sort_keys=False)
with ZipFile(output, "a", ZIP_DEFLATED, False) as zipfile:
zipfile.writestr(
"scn.yaml",
yaml.dump(game.scn, allow_unicode=True, sort_keys=False).encode("utf8"),
)
zipfile.writestr("scn.yaml", data.encode("utf8"))
zipfile.writestr(RESULTS_FILENAME, json.dumps(game.stat, ensure_ascii=False, indent=2))
for guid, content in game.files.items():
zipfile.writestr(guid, content.read())
Expand Down

0 comments on commit b926e88

Please sign in to comment.