From 4b817f99d89b4ff2a7009b702afa01554ded3c1c Mon Sep 17 00:00:00 2001 From: Okapi1023 Date: Tue, 1 Sep 2026 19:57:36 +0100 Subject: [PATCH 1/8] 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/8] 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/8] 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"), }, From 2ed1cd94c2971cd0832e57ca804f614c7ba8df7a Mon Sep 17 00:00:00 2001 From: Okapi1023 Date: Tue, 1 Sep 2026 20:21:57 +0100 Subject: [PATCH 4/8] Refactor file paths and improve comments in build.py --- data/v2/build.py | 64 +++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 36 deletions(-) diff --git a/data/v2/build.py b/data/v2/build.py index 92fff5f04..e71b1c130 100644 --- a/data/v2/build.py +++ b/data/v2/build.py @@ -1,3 +1,16 @@ +# 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 @@ -7,9 +20,9 @@ from pokemon_v2.models import * -BASE_DIR = os.path.dirname(os.path.abspath(__file__)) -DATA_LOCATION = os.path.join(BASE_DIR, "csv") - +# why this way? how about use `__file__` +DATA_LOCATION = "data/v2/csv/" +DATA_LOCATION2 = os.path.join(os.path.dirname(__file__), "csv") GROUP_RGX = r"\[(.*?)\]\{(.*?)\}" SUB_RGX = r"\[.*?\]\{.*?\}" @@ -29,20 +42,20 @@ "https://raw.githubusercontent.com/PokeAPI/cries/main/cries/", ) ) -IMAGE_DIR = os.path.join(BASE_DIR, "sprites", "sprites") -CRIES_DIR = os.path.join(BASE_DIR, "cries", "cries") +IMAGE_DIR = os.getcwd() + "/data/v2/sprites/sprites/" +CRIES_DIR = os.getcwd() + "/data/v2/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.relpath(os.path.join(root, file), IMAGE_DIR) + image_path = os.path.join(root.replace(IMAGE_DIR, ""), file) 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.relpath(os.path.join(root, file), CRIES_DIR) + cry_path = os.path.join(root.replace(CRIES_DIR, ""), file) cry_path = cry_path.replace("\\", "/") # convert Windows-style path to Unix RESOURCE_CRIES.append(cry_path) @@ -62,8 +75,7 @@ def with_iter(context, iterable=None): def load_data(file_name): # with_iter closes the file when it has finished - file_path = os.path.join(DATA_LOCATION, file_name) - return csv.reader(with_iter(open(file_path, encoding="utf8")), delimiter=",") + return csv.reader(with_iter(open(DATA_LOCATION + file_name, encoding="utf8")), delimiter=",") def clear_table(model): @@ -249,9 +261,9 @@ def csv_record_to_objects(info): build_generic((PokeathlonStatName,), "pokeathlon_stat_names.csv", csv_record_to_objects) -############### -# ABILITIES # -############### +# ############### +# # ABILITIES # +# ############### def _build_abilities(): @@ -360,9 +372,9 @@ def csv_record_to_objects(info): build_generic((GrowthRateDescription,), "growth_rate_prose.csv", csv_record_to_objects) -########### -# ITEMS # -########### +# ########### +# # ITEMS # +# ########### def _build_items(): @@ -1333,12 +1345,6 @@ 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"), @@ -1347,19 +1353,11 @@ 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"), @@ -1367,17 +1365,11 @@ 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": { @@ -1736,7 +1728,7 @@ def csv_record_to_objects(info): ), "champions": { "front_default": try_image_names(poke_sprites + gen_ix + "champions/", info, "png"), - }, + } }, }, } From f068e64db0c4b4065e3bc50f5ecfc2ba9f089d96 Mon Sep 17 00:00:00 2001 From: Okapi1023 Date: Tue, 1 Sep 2026 20:26:42 +0100 Subject: [PATCH 5/8] Add image handling for red-green-japan version --- data/v2/build.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/data/v2/build.py b/data/v2/build.py index e71b1c130..d59ccc344 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"), @@ -1353,11 +1359,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"), @@ -1365,11 +1379,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 f90b9f5ed783f67501da4e4165fca9c962ea20b9 Mon Sep 17 00:00:00 2001 From: Okapi1023 Date: Tue, 1 Sep 2026 20:47:37 +0100 Subject: [PATCH 6/8] Fix syntax error in build.py --- data/v2/build.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/data/v2/build.py b/data/v2/build.py index d59ccc344..ae47fe6f9 100644 --- a/data/v2/build.py +++ b/data/v2/build.py @@ -1746,9 +1746,10 @@ def csv_record_to_objects(info): info, "png", ), + }, "champions": { "front_default": try_image_names(poke_sprites + gen_ix + "champions/", info, "png"), - } + }, }, }, } From 3dbc898f7008299cd4b637ac244acfa0402c04b6 Mon Sep 17 00:00:00 2001 From: Okapi1023 Date: Tue, 1 Sep 2026 21:13:27 +0100 Subject: [PATCH 7/8] Add 'champions' to generation-ix game list --- data/v2/build.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/data/v2/build.py b/data/v2/build.py index ae47fe6f9..5e100a4c3 100644 --- a/data/v2/build.py +++ b/data/v2/build.py @@ -591,7 +591,7 @@ def csv_record_to_objects(info): "legends-arceus", "sword-shield", ], - "generation-ix": ["scarlet-violet"], + "generation-ix": ["champions", "scarlet-violet"], } sprites = {} for generation, games in game_map.items(): @@ -1923,7 +1923,10 @@ def csv_record_to_objects(info): info, "png", ), - } + }, + "champions": { + "front_default": try_image_names(poke_sprites + gen_ix + "champions/", info, "png"), + }, }, }, } From 71f2078f8c337b2bd4104959aa714dede5903465 Mon Sep 17 00:00:00 2001 From: Okapi1023 Date: Tue, 1 Sep 2026 21:21:35 +0100 Subject: [PATCH 8/8] Update champion sprite path for generation IX --- data/v2/build.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/data/v2/build.py b/data/v2/build.py index 5e100a4c3..670e620ec 100644 --- a/data/v2/build.py +++ b/data/v2/build.py @@ -1925,7 +1925,11 @@ def csv_record_to_objects(info): ), }, "champions": { - "front_default": try_image_names(poke_sprites + gen_ix + "champions/", info, "png"), + "front_default": try_form_image_names( + poke_sprites + "versions/generation-ix/champions/", + info, + "png", + ), }, }, },