From 8dda8db72fe2ebc0e0e3749b811d85dfe9c677d3 Mon Sep 17 00:00:00 2001 From: LDericher <40151420+ldericher@users.noreply.github.com> Date: Mon, 9 Aug 2021 05:32:05 +0200 Subject: [PATCH] Python3.9 --- LICENSE | 2 +- Pipfile | 2 +- Pipfile.lock | 4 ++-- fftcg/book.py | 5 ++--- fftcg/card.py | 6 ++---- fftcg/cards.py | 6 ++---- fftcg/imageloader.py | 9 ++++----- fftcg/opus.py | 19 +++++++++---------- 8 files changed, 23 insertions(+), 30 deletions(-) diff --git a/LICENSE b/LICENSE index f288702..282cc2a 100644 --- a/LICENSE +++ b/LICENSE @@ -407,7 +407,7 @@ the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or +provided under this License. any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). diff --git a/Pipfile b/Pipfile index fb91dc7..70327e4 100644 --- a/Pipfile +++ b/Pipfile @@ -11,4 +11,4 @@ pillow = "*" roman = "*" [requires] -python_version = "3.8" +python_version = "3.9" diff --git a/Pipfile.lock b/Pipfile.lock index 79f790d..e9ad351 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,11 +1,11 @@ { "_meta": { "hash": { - "sha256": "fe611914a3a46d2834978ca4ab586c8273140df68e5fc593e585770f27e145ab" + "sha256": "a2e1b3f733a9b7697e8f974449a04cf81e78f6959a67945afa0e78446d491690" }, "pipfile-spec": 6, "requires": { - "python_version": "3.8" + "python_version": "3.9" }, "sources": [ { diff --git a/fftcg/book.py b/fftcg/book.py index 14e162d..a3fa142 100644 --- a/fftcg/book.py +++ b/fftcg/book.py @@ -1,5 +1,4 @@ import logging -from typing import List, Tuple, Any from PIL import Image @@ -7,7 +6,7 @@ from .cards import Cards from .imageloader import ImageLoader -def chunks(whole: List[Any], chunk_size) -> List: +def chunks(whole: list[any], chunk_size) -> list: # while there are elements while whole: # get a chunk @@ -23,7 +22,7 @@ class Book: # Card back image by Aurik __BACK_URL = "http://cloud-3.steamusercontent.com/ugc/948455238665576576/85063172B8C340602E8D6C783A457122F53F7843/" - def __init__(self, cards: Cards, grid: Tuple[int, int], resolution: Tuple[int, int], language: str, + def __init__(self, cards: Cards, grid: tuple[int, int], resolution: tuple[int, int], language: str, num_threads: int): logger = logging.getLogger(__name__) diff --git a/fftcg/card.py b/fftcg/card.py index fa799f7..8fd5c1d 100644 --- a/fftcg/card.py +++ b/fftcg/card.py @@ -1,7 +1,5 @@ import re -from typing import List, Dict, Any - class Card: __ELEMENTS_MAP = { @@ -15,7 +13,7 @@ class Card: '闇': "Darkness" } - def __init__(self, data: Dict[str, Any], language: str = "EN"): + def __init__(self, data: dict[str, any], language: str = "EN"): if not data: self.__opus = "0" self.__serial = "000" @@ -79,5 +77,5 @@ class Card: return self.__text @property - def elements(self) -> List[str]: + def elements(self) -> list[str]: return self.__elements diff --git a/fftcg/cards.py b/fftcg/cards.py index 46b764c..801908c 100644 --- a/fftcg/cards.py +++ b/fftcg/cards.py @@ -1,14 +1,12 @@ -from typing import Dict, Any, List - import requests from .card import Card -class Cards(List[Card]): +class Cards(list[Card]): __API_URL = "https://fftcg.square-enix-games.com/de/get-cards" - def __init__(self, params: Dict[str, Any]): + def __init__(self, params: dict[str, any]): list.__init__(self) # required params: diff --git a/fftcg/imageloader.py b/fftcg/imageloader.py index 164d532..4242b97 100644 --- a/fftcg/imageloader.py +++ b/fftcg/imageloader.py @@ -2,14 +2,13 @@ import io import logging import queue import threading -from typing import List, Tuple, Dict import requests from PIL import Image class ImageLoader(threading.Thread): - def __init__(self, url_queue: queue.Queue, resolution: Tuple[int, int], language: str): + def __init__(self, url_queue: queue.Queue, resolution: tuple[int, int], language: str): threading.Thread.__init__(self) self.__queue = url_queue @@ -45,7 +44,7 @@ class ImageLoader(threading.Thread): self.__queue.task_done() @classmethod - def load(cls, urls: List[str], resolution: Tuple[int, int], language: str, num_threads: int) -> List[Image.Image]: + def load(cls, urls: list[str], resolution: tuple[int, int], language: str, num_threads: int) -> list[Image.Image]: url_queue = queue.Queue() for url in urls: url_queue.put(url) @@ -61,7 +60,7 @@ class ImageLoader(threading.Thread): # stitch all "images" dicts together images = {} for loader in loaders: - images = {**images, **loader.images} + images |= loader.images # sort images to match the initial "urls" list images = [images[url] for url in urls] @@ -69,5 +68,5 @@ class ImageLoader(threading.Thread): return images @property - def images(self) -> Dict[str, Image.Image]: + def images(self) -> dict[str, Image.Image]: return self.__images diff --git a/fftcg/opus.py b/fftcg/opus.py index f4a1946..e992e1c 100644 --- a/fftcg/opus.py +++ b/fftcg/opus.py @@ -9,33 +9,32 @@ class Opus(Cards): def __init__(self, opus_id: str): logger = logging.getLogger(__name__) + params: dict[str, any] = { + "text": "", + # "element": ["darkness"], + } + if opus_id.isnumeric(): roman_opus_id = roman.toRoman(int(opus_id)) - params_add = {"set": [f"Opus {roman_opus_id.upper()}"]} + params |= {"set": [f"Opus {roman_opus_id.upper()}"]} self.__number = opus_id self.__name = f"opus_{opus_id}" elif opus_id == "chaos": - params_add = {"set": ["Boss Deck Chaos"]} + params |= {"set": ["Boss Deck Chaos"]} self.__number = "B" self.__name = "boss_deck_chaos" elif opus_id == "promo": - params_add = {"rarity": ["pr"]} + params |= {"rarity": ["pr"]} self.__number = "PR" self.__name = "promo" else: - params_add = {"set": ["?"]} + params |= {"set": ["?"]} self.__number = "?" self.__name = "?" - params = { - "text": "", - # "element": ["darkness"], - **params_add - } - Cards.__init__(self, params) # remove reprints