mirror of
https://github.com/ldericher/fftcgtool
synced 2025-01-15 15:02:59 +00:00
skip buffer usage
This commit is contained in:
parent
349e7970d5
commit
1294cc3a38
1 changed files with 5 additions and 10 deletions
15
fftcgtool.py
15
fftcgtool.py
|
@ -1,6 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import argparse
|
import argparse
|
||||||
import io
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -156,19 +155,15 @@ def main() -> None:
|
||||||
|
|
||||||
# decide what to do with the decks
|
# decide what to do with the decks
|
||||||
if args.stdout:
|
if args.stdout:
|
||||||
# create file-like buffer
|
# print out a zip file
|
||||||
with io.BytesIO() as buffer:
|
with open(sys.stdout.fileno(), "wb", closefd=False, buffering=0) as raw_stdout:
|
||||||
# create zip file in buffer
|
with zipfile.ZipFile(raw_stdout, "w", compression=zipfile.ZIP_DEFLATED) as zip_file:
|
||||||
with zipfile.ZipFile(buffer, "w") as zip_file:
|
# put the decks into that zip file
|
||||||
for deck in decks:
|
for deck in decks:
|
||||||
zip_file.writestr(deck.file_name, deck.get_json(args.language))
|
zip_file.writestr(deck.file_name, deck.get_json(args.language))
|
||||||
|
|
||||||
# write buffer to stdout
|
|
||||||
buffer.seek(0)
|
|
||||||
with open(sys.stdout.fileno(), "wb", closefd=False, buffering=0) as stdout:
|
|
||||||
stdout.write(buffer.read())
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
# save the decks to disk
|
||||||
for deck in decks:
|
for deck in decks:
|
||||||
deck.save(args.language)
|
deck.save(args.language)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue