mirror of
https://github.com/ldericher/fftcgtool
synced 2025-01-15 15:02:59 +00:00
stronger typing
This commit is contained in:
parent
bbae21d3b9
commit
65a0ebd37f
4 changed files with 10 additions and 9 deletions
|
@ -2,6 +2,7 @@ import logging
|
|||
|
||||
from PIL import Image
|
||||
|
||||
from .cards import Cards
|
||||
from .imageloader import ImageLoader
|
||||
|
||||
|
||||
|
@ -21,7 +22,7 @@ class Book:
|
|||
# Card back image by Aurik
|
||||
__BACK_URL = "http://cloud-3.steamusercontent.com/ugc/948455238665576576/85063172B8C340602E8D6C783A457122F53F7843/"
|
||||
|
||||
def __init__(self, cards, grid, resolution, language, num_threads):
|
||||
def __init__(self, cards: Cards, grid: tuple, resolution: tuple, language: str, num_threads: int):
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# sort cards by element, then alphabetically
|
||||
|
@ -46,7 +47,7 @@ class Book:
|
|||
# width, height per card
|
||||
w, h = resolution
|
||||
|
||||
def paste_image(page, index, image):
|
||||
def paste_image(page: Image, index: int, image: Image):
|
||||
x, y = (index % c) * w, (index // c) * h
|
||||
page.paste(image, (x, y))
|
||||
|
||||
|
@ -65,6 +66,6 @@ class Book:
|
|||
|
||||
self.__pages.append(page)
|
||||
|
||||
def save(self, filename):
|
||||
def save(self, filename: str):
|
||||
for i, page in enumerate(self.__pages):
|
||||
page.save(filename.format(i))
|
||||
|
|
|
@ -13,7 +13,7 @@ class Card:
|
|||
'闇': "Darkness"
|
||||
}
|
||||
|
||||
def __init__(self, data, language="EN"):
|
||||
def __init__(self, data: dict, language: str = "EN"):
|
||||
if not data:
|
||||
self.__opus = "0"
|
||||
self.__serial = "000"
|
||||
|
|
|
@ -8,7 +8,7 @@ from PIL import Image
|
|||
|
||||
|
||||
class ImageLoader(threading.Thread):
|
||||
def __init__(self, url_queue, resolution, language):
|
||||
def __init__(self, url_queue: queue.Queue, resolution: tuple, language: str):
|
||||
threading.Thread.__init__(self)
|
||||
|
||||
self.__queue = url_queue
|
||||
|
@ -44,7 +44,7 @@ class ImageLoader(threading.Thread):
|
|||
self.__queue.task_done()
|
||||
|
||||
@classmethod
|
||||
def load(cls, urls, resolution, language, num_threads):
|
||||
def load(cls, urls: list, resolution: tuple, language: str, num_threads: int):
|
||||
url_queue = queue.Queue()
|
||||
for url in urls:
|
||||
url_queue.put(url)
|
||||
|
|
|
@ -6,13 +6,13 @@ from .cards import Cards
|
|||
|
||||
|
||||
class Opus(Cards):
|
||||
def __init__(self, opus_id):
|
||||
def __init__(self, opus_id: str):
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if isinstance(opus_id, str) and opus_id.isnumeric():
|
||||
if opus_id.isnumeric():
|
||||
roman_opus_id = roman.toRoman(int(opus_id))
|
||||
params_add = {"set": [f"Opus {roman_opus_id.upper()}"]}
|
||||
self.__number = str(opus_id)
|
||||
self.__number = opus_id
|
||||
self.__name = f"opus_{opus_id}"
|
||||
|
||||
elif opus_id == "chaos":
|
||||
|
|
Loading…
Reference in a new issue