1
0
Fork 0
mirror of https://github.com/ldericher/fftcgtool synced 2025-01-15 15:02:59 +00:00

compression

This commit is contained in:
Jörn-Michael Miehe 2021-08-23 13:43:12 +02:00
parent f286a0a2bb
commit 1a3ec4ff32
3 changed files with 6 additions and 4 deletions

View file

@ -1,4 +1,5 @@
import logging
import bz2
import pickle
from PIL import Image
@ -64,7 +65,7 @@ class Book:
book: dict[str, Cards]
try:
with open(BOOK_PICKLE_NAME, "rb") as file:
with bz2.BZ2File(BOOK_PICKLE_NAME, "r") as file:
book = pickle.load(file)
except FileNotFoundError:
book = {}
@ -79,5 +80,5 @@ class Book:
book[page["file_name"]] = page["cards"]
# update book.yml file
with open(BOOK_PICKLE_NAME, "wb") as file:
with bz2.BZ2File(BOOK_PICKLE_NAME, "w") as file:
pickle.dump(book, file)

View file

@ -1,5 +1,6 @@
from __future__ import annotations
import bz2
import pickle
from fftcg import Card
@ -27,7 +28,7 @@ class CardDB:
# load book.yml file
book: dict
try:
with open(BOOK_PICKLE_NAME, "rb") as file:
with bz2.BZ2File(BOOK_PICKLE_NAME, "r") as file:
book = pickle.load(file)
except FileNotFoundError:
book = {}

View file

@ -3,7 +3,7 @@ from .grid import Grid
# constants
GRID = Grid((10, 7)) # default in TTsim: 10 columns, 7 rows
RESOLUTION = Grid((429, 600)) # default in TTsim: 480x670 pixels per card
BOOK_PICKLE_NAME = "book.pickle"
BOOK_PICKLE_NAME = "book.pickle.bz2"
# card back URL (image by Aurik)
CARD_BACK_URL = "http://cloud-3.steamusercontent.com/ugc/948455238665576576/85063172B8C340602E8D6C783A457122F53F7843/"