From 4b817f99d89b4ff2a7009b702afa01554ded3c1c Mon Sep 17 00:00:00 2001 From: Okapi1023 Date: Tue, 1 Sep 2026 19:57:36 +0100 Subject: [PATCH 1/3] Add red-green-japan sprite variations to build.py --- data/v2/build.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/data/v2/build.py b/data/v2/build.py index 4a75fe6e5..e8f64301b 100644 --- a/data/v2/build.py +++ b/data/v2/build.py @@ -1345,6 +1345,12 @@ def csv_record_to_objects(info): }, "versions": { "generation-i": { + "red-green-japan": { + "front_default": try_image_names(poke_sprites + gen_i + "red-green-japan/", info, "png"), + "front_gray": try_image_names(poke_sprites + gen_i + "red-green-japan/gray/", info, "png"), + "back_default": try_image_names(poke_sprites + gen_i + "red-green-japan/back/", info, "png"), + "back_gray": try_image_names(poke_sprites + gen_i + "red-green-japan/back/gray/", info, "png"), + }, "red-blue": { "front_default": try_image_names(poke_sprites + gen_i + "red-blue/", info, "png"), "front_gray": try_image_names(poke_sprites + gen_i + "red-blue/gray/", info, "png"), @@ -1365,11 +1371,17 @@ def csv_record_to_objects(info): "back_default": try_image_names(poke_sprites + gen_i + "yellow/back/", info, "png"), "back_gray": try_image_names(poke_sprites + gen_i + "yellow/back/gray/", info, "png"), "front_transparent": try_image_names(poke_sprites + gen_i + "yellow/transparent/", info, "png"), + "front_transparent_gray": try_image_names(poke_sprites + gen_i + "yellow/transparent/gray", info, "png"), "back_transparent": try_image_names( poke_sprites + gen_i + "yellow/transparent/back/", info, "png", ), + "back_transparent_gray": try_image_names( + poke_sprites + gen_i + "yellow/transparent/back/gray", + info, + "png", + ), }, }, "generation-ii": { From 8c3167fbf7907644e106463d326235afc43391d0 Mon Sep 17 00:00:00 2001 From: Okapi1023 Date: Tue, 1 Sep 2026 20:15:10 +0100 Subject: [PATCH 2/3] Refactor build.py for improved file path handling Refactor file paths to use BASE_DIR for better portability. Update comments for clarity. --- data/v2/build.py | 55 ++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/data/v2/build.py b/data/v2/build.py index 874c90ef0..d6cd4cf1f 100644 --- a/data/v2/build.py +++ b/data/v2/build.py @@ -1,16 +1,3 @@ -# To build out the data you'll need to jump into the Django shell -# -# $ uv run manage.py shell -# -# and run the build script with -# -# $ from data.v2.build import build_all -# $ build_all() -# -# Each time the build script is run it will iterate over each table in the database, -# wipe it and rewrite each row using the data found in data/v2/csv. - - import csv import os import os.path @@ -20,9 +7,9 @@ from pokemon_v2.models import * -# why this way? how about use `__file__` -DATA_LOCATION = "data/v2/csv/" -DATA_LOCATION2 = os.path.join(os.path.dirname(__file__), "csv") +BASE_DIR = os.path.dirname(os.path.abspath(__file__)) +DATA_LOCATION = os.path.join(BASE_DIR, "csv") + GROUP_RGX = r"\[(.*?)\]\{(.*?)\}" SUB_RGX = r"\[.*?\]\{.*?\}" @@ -42,20 +29,20 @@ "https://raw.githubusercontent.com/PokeAPI/cries/main/cries/", ) ) -IMAGE_DIR = os.getcwd() + "/data/v2/sprites/sprites/" -CRIES_DIR = os.getcwd() + "/data/v2/cries/cries/" +IMAGE_DIR = os.path.join(BASE_DIR, "sprites", "sprites") +CRIES_DIR = os.path.join(BASE_DIR, "cries", "cries") RESOURCE_IMAGES: list[str] = [] RESOURCE_CRIES: list[str] = [] for root, _dirs, files in os.walk(IMAGE_DIR): for file in files: - image_path = os.path.join(root.replace(IMAGE_DIR, ""), file) + image_path = os.path.relpath(os.path.join(root, file), IMAGE_DIR) image_path = image_path.replace("\\", "/") # convert Windows-style path to Unix RESOURCE_IMAGES.append(image_path) for root, _dirs, files in os.walk(CRIES_DIR): for file in files: - cry_path = os.path.join(root.replace(CRIES_DIR, ""), file) + cry_path = os.path.relpath(os.path.join(root, file), CRIES_DIR) cry_path = cry_path.replace("\\", "/") # convert Windows-style path to Unix RESOURCE_CRIES.append(cry_path) @@ -75,7 +62,8 @@ def with_iter(context, iterable=None): def load_data(file_name): # with_iter closes the file when it has finished - return csv.reader(with_iter(open(DATA_LOCATION + file_name, encoding="utf8")), delimiter=",") + file_path = os.path.join(DATA_LOCATION, file_name) + return csv.reader(with_iter(open(file_path, encoding="utf8")), delimiter=",") def clear_table(model): @@ -261,9 +249,9 @@ def csv_record_to_objects(info): build_generic((PokeathlonStatName,), "pokeathlon_stat_names.csv", csv_record_to_objects) -# ############### -# # ABILITIES # -# ############### +############### +# ABILITIES # +############### def _build_abilities(): @@ -372,9 +360,9 @@ def csv_record_to_objects(info): build_generic((GrowthRateDescription,), "growth_rate_prose.csv", csv_record_to_objects) -# ########### -# # ITEMS # -# ########### +########### +# ITEMS # +########### def _build_items(): @@ -1359,11 +1347,19 @@ def csv_record_to_objects(info): "front_transparent": try_image_names( poke_sprites + gen_i + "red-blue/transparent/", info, "png" ), + "front_transparent_gray": try_image_names( + poke_sprites + gen_i + "red-blue/transparent/gray", info, "png" + ), "back_transparent": try_image_names( poke_sprites + gen_i + "red-blue/transparent/back/", info, "png", ), + "back_transparent_gray": try_image_names( + poke_sprites + gen_i + "red-blue/transparent/back/gray", + info, + "png", + ), }, "yellow": { "front_default": try_image_names(poke_sprites + gen_i + "yellow/", info, "png"), @@ -1738,7 +1734,10 @@ def csv_record_to_objects(info): info, "png", ), - } + }, + "champions": { + "front_default": try_image_names(poke_sprites + gen_ix + "champions/", info, "png"), + }, }, }, } From f8bfe74184182e6c9c6ed3718998f848fbd398f5 Mon Sep 17 00:00:00 2001 From: Okapi1023 Date: Tue, 1 Sep 2026 20:17:40 +0100 Subject: [PATCH 3/3] Remove unused closing brace in build.py --- data/v2/build.py | 1 - 1 file changed, 1 deletion(-) diff --git a/data/v2/build.py b/data/v2/build.py index d6cd4cf1f..92fff5f04 100644 --- a/data/v2/build.py +++ b/data/v2/build.py @@ -1734,7 +1734,6 @@ def csv_record_to_objects(info): info, "png", ), - }, "champions": { "front_default": try_image_names(poke_sprites + gen_ix + "champions/", info, "png"), },