mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-22 19:33:10 +00:00
feat: polish code/add female forms sprites
This commit is contained in:
parent
808a7a8742
commit
0391268426
1 changed files with 307 additions and 481 deletions
788
data/v2/build.py
788
data/v2/build.py
|
@ -1348,623 +1348,436 @@ def _build_pokemons():
|
||||||
|
|
||||||
build_generic((Pokemon,), "pokemon.csv", csv_record_to_objects)
|
build_generic((Pokemon,), "pokemon.csv", csv_record_to_objects)
|
||||||
|
|
||||||
def try_image_names(info):
|
def try_image_names(path, info, extension):
|
||||||
poke_sprites = "pokemon/{0}"
|
# poke_sprites = "pokemon/{0}"
|
||||||
if "-" in info[1]:
|
pokemon_id = info[0]
|
||||||
file_name_png_str = "%s.png" % (info[2] + "-" + info[1].split("-", 1)[1],)
|
identifier = info[1]
|
||||||
file_name_png_int = "%s.png" % info[0]
|
species_id = info[2]
|
||||||
file_name_png = (
|
if "-" in identifier:
|
||||||
file_name_png_str
|
file_name_str = "%s.%s" % (
|
||||||
if file_path_or_none(poke_sprites.format(file_name_png_str))
|
species_id + "-" + identifier.split("-", 1)[1],
|
||||||
else file_name_png_int
|
extension,
|
||||||
|
)
|
||||||
|
file_name_int = "%s.%s" % (pokemon_id, extension)
|
||||||
|
file_name = (
|
||||||
|
file_name_int
|
||||||
|
if file_path_or_none(path + file_name_int)
|
||||||
|
else file_name_str
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
file_name_png = "%s.png" % info[0]
|
file_name = "%s.%s" % (info[0], extension)
|
||||||
return file_name_png
|
return file_path_or_none(path + file_name)
|
||||||
|
|
||||||
def csv_record_to_objects(info):
|
def csv_record_to_objects(info):
|
||||||
file_name_png = try_image_names(info)
|
poke_sprites = "pokemon/"
|
||||||
file_name_gif = "%s.gif" % info[0]
|
dream_world = "other/dream-world/"
|
||||||
file_name_svg = "%s.svg" % info[0]
|
official_art = "other/official-artwork/"
|
||||||
poke_sprites = "pokemon/{0}"
|
gen_i = "versions/generation-i/"
|
||||||
dream_world = "other/dream-world/{0}"
|
gen_ii = "versions/generation-ii/"
|
||||||
official_art = "other/official-artwork/{0}"
|
gen_iii = "versions/generation-iii/"
|
||||||
gen_i = "versions/generation-i/{0}"
|
gen_iv = "versions/generation-iv/"
|
||||||
gen_ii = "versions/generation-ii/{0}"
|
gen_v = "versions/generation-v/"
|
||||||
gen_iii = "versions/generation-iii/{0}"
|
gen_vi = "versions/generation-vi/"
|
||||||
gen_iv = "versions/generation-iv/{0}"
|
gen_vii = "versions/generation-vii/"
|
||||||
gen_v = "versions/generation-v/{0}"
|
gen_viii = "versions/generation-viii/"
|
||||||
gen_vi = "versions/generation-vi/{0}"
|
|
||||||
gen_vii = "versions/generation-vii/{0}"
|
|
||||||
gen_viii = "versions/generation-viii/{0}"
|
|
||||||
sprites = {
|
sprites = {
|
||||||
"front_default": file_path_or_none(poke_sprites.format(file_name_png)),
|
"front_default": try_image_names(poke_sprites, info, "png"),
|
||||||
"front_female": file_path_or_none(
|
"front_female": try_image_names(poke_sprites + "female/", info, "png"),
|
||||||
poke_sprites.format("female/" + file_name_png)
|
"front_shiny": try_image_names(poke_sprites + "shiny/", info, "png"),
|
||||||
|
"front_shiny_female": try_image_names(
|
||||||
|
poke_sprites + "shiny/female/", info, "png"
|
||||||
),
|
),
|
||||||
"front_shiny": file_path_or_none(
|
"back_default": try_image_names(poke_sprites + "back/", info, "png"),
|
||||||
poke_sprites.format("shiny/" + file_name_png)
|
"back_female": try_image_names(poke_sprites + "back/female/", info, "png"),
|
||||||
),
|
"back_shiny": try_image_names(poke_sprites + "back/shiny/", info, "png"),
|
||||||
"front_shiny_female": file_path_or_none(
|
"back_shiny_female": try_image_names(
|
||||||
poke_sprites.format("shiny/female/" + file_name_png)
|
poke_sprites + "back/shiny/female/", info, "png"
|
||||||
),
|
|
||||||
"back_default": file_path_or_none(
|
|
||||||
poke_sprites.format("back/" + file_name_png)
|
|
||||||
),
|
|
||||||
"back_female": file_path_or_none(
|
|
||||||
poke_sprites.format("back/female/" + file_name_png)
|
|
||||||
),
|
|
||||||
"back_shiny": file_path_or_none(
|
|
||||||
poke_sprites.format("back/shiny/" + file_name_png)
|
|
||||||
),
|
|
||||||
"back_shiny_female": file_path_or_none(
|
|
||||||
poke_sprites.format("back/shiny/female/" + file_name_png)
|
|
||||||
),
|
),
|
||||||
"other": {
|
"other": {
|
||||||
"dream_world": {
|
"dream_world": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(dream_world.format(file_name_svg))
|
poke_sprites + dream_world, info, 'svg'
|
||||||
),
|
),
|
||||||
"front_female": file_path_or_none(
|
"front_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + dream_world + "female/", info, 'svg'
|
||||||
dream_world.format("female/" + file_name_svg)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
"official-artwork": {
|
"official-artwork": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(official_art.format(file_name_png))
|
poke_sprites + official_art, info, 'png'
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"versions": {
|
"versions": {
|
||||||
"generation-i": {
|
"generation-i": {
|
||||||
"red-blue": {
|
"red-blue": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_i + "red-blue/", info, 'png'
|
||||||
gen_i.format("red-blue/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_gray": file_path_or_none(
|
"front_gray": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_i + "red-blue/gray/", info, 'png'
|
||||||
gen_i.format("red-blue/gray/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_default": file_path_or_none(
|
"back_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_i + "red-blue/back/", info, 'png'
|
||||||
gen_i.format("red-blue/back/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_gray": file_path_or_none(
|
"back_gray": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_i + "red-blue/back/gray/", info, 'png'
|
||||||
gen_i.format("red-blue/back/gray/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
"yellow": {
|
"yellow": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(gen_i.format("yellow/" + file_name_png))
|
poke_sprites + gen_i + "yellow/", info, 'png'
|
||||||
),
|
),
|
||||||
"front_gray": file_path_or_none(
|
"front_gray": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_i + "yellow/gray/", info, 'png'
|
||||||
gen_i.format("yellow/gray/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_default": file_path_or_none(
|
"back_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_i + "yellow/back/", info, 'png'
|
||||||
gen_i.format("yellow/back/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_gray": file_path_or_none(
|
"back_gray": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_i + "yellow/back/gray/", info, 'png'
|
||||||
gen_i.format("yellow/back/gray/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"generation-ii": {
|
"generation-ii": {
|
||||||
"crystal": {
|
"crystal": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_ii + "crystal/", info, 'png'
|
||||||
gen_ii.format("crystal/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny": file_path_or_none(
|
"front_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_ii + "crystal/shiny/", info, 'png'
|
||||||
gen_ii.format("crystal/shiny/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_default": file_path_or_none(
|
"back_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_ii + "crystal/back/", info, 'png'
|
||||||
gen_ii.format("crystal/back/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_shiny": file_path_or_none(
|
"back_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_ii + "crystal/back/shiny/", info, 'png'
|
||||||
gen_ii.format("crystal/back/shiny/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
"gold": {
|
"gold": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(gen_ii.format("gold/" + file_name_png))
|
poke_sprites + gen_ii + "gold/", info, 'png'
|
||||||
),
|
),
|
||||||
"front_shiny": file_path_or_none(
|
"front_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_ii + "gold/shiny/", info, 'png'
|
||||||
gen_ii.format("gold/shiny/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_default": file_path_or_none(
|
"back_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_ii + "gold/back/", info, 'png'
|
||||||
gen_ii.format("gold/back/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_shiny": file_path_or_none(
|
"back_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_ii + "gold/back/shiny/", info, 'png'
|
||||||
gen_ii.format("gold/back/shiny/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
"silver": {
|
"silver": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_ii + "silver/", info, 'png'
|
||||||
gen_ii.format("silver/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny": file_path_or_none(
|
"front_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_ii + "silver/shiny/", info, 'png'
|
||||||
gen_ii.format("silver/shiny/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_default": file_path_or_none(
|
"back_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_ii + "silver/back/", info, 'png'
|
||||||
gen_ii.format("silver/back/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_shiny": file_path_or_none(
|
"back_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_ii + "silver/back/shiny/", info, 'png'
|
||||||
gen_ii.format("silver/back/shiny/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"generation-iii": {
|
"generation-iii": {
|
||||||
"emerald": {
|
"emerald": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iii + "emerald/", info, 'png'
|
||||||
gen_iii.format("emerald/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny": file_path_or_none(
|
"front_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iii + "emerald/shiny/", info, 'png'
|
||||||
gen_iii.format("emerald/shiny/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
"firered-leafgreen": {
|
"firered-leafgreen": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iii + "firered-leafgreen/", info, 'png'
|
||||||
gen_iii.format("firered-leafgreen/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny": file_path_or_none(
|
"front_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iii + "firered-leafgreen/shiny/",
|
||||||
gen_iii.format(
|
info, 'png',
|
||||||
"firered-leafgreen/shiny/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_default": file_path_or_none(
|
"back_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iii + "firered-leafgreen/back/",
|
||||||
gen_iii.format(
|
info, 'png',
|
||||||
"firered-leafgreen/back/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_shiny": file_path_or_none(
|
"back_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iii + "firered-leafgreen/back/shiny/",
|
||||||
gen_iii.format(
|
info, 'png',
|
||||||
"firered-leafgreen/back/shiny/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
"ruby-sapphire": {
|
"ruby-sapphire": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iii + "ruby-sapphire/", info, 'png'
|
||||||
gen_iii.format("ruby-sapphire/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny": file_path_or_none(
|
"front_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iii + "ruby-sapphire/shiny/",
|
||||||
gen_iii.format("ruby-sapphire/shiny/" + file_name_png)
|
info, 'png',
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_default": file_path_or_none(
|
"back_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iii + "ruby-sapphire/back/",
|
||||||
gen_iii.format("ruby-sapphire/back/" + file_name_png)
|
info, 'png',
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_shiny": file_path_or_none(
|
"back_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iii + "ruby-sapphire/back/shiny/",
|
||||||
gen_iii.format(
|
info, 'png',
|
||||||
"ruby-sapphire/back/shiny/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"generation-iv": {
|
"generation-iv": {
|
||||||
"diamond-pearl": {
|
"diamond-pearl": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "diamond-pearl/", info, 'png'
|
||||||
gen_iv.format("diamond-pearl/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_female": file_path_or_none(
|
"front_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "diamond-pearl/female/",
|
||||||
gen_iv.format("diamond-pearl/female/" + file_name_png)
|
info, 'png',
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny": file_path_or_none(
|
"front_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "diamond-pearl/shiny/",
|
||||||
gen_iv.format("diamond-pearl/shiny/" + file_name_png)
|
info, 'png',
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny_female": file_path_or_none(
|
"front_shiny_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "diamond-pearl/shiny/female/",
|
||||||
gen_iv.format(
|
info, 'png',
|
||||||
"diamond-pearl/shiny/female/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_default": file_path_or_none(
|
"back_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "diamond-pearl/back/", info, 'png'
|
||||||
gen_iv.format("diamond-pearl/back/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_female": file_path_or_none(
|
"back_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "diamond-pearl/back/female/",
|
||||||
gen_iv.format(
|
info, 'png',
|
||||||
"diamond-pearl/back/female/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_shiny": file_path_or_none(
|
"back_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "diamond-pearl/back/shiny/",
|
||||||
gen_iv.format(
|
info, 'png',
|
||||||
"diamond-pearl/back/shiny/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_shiny_female": file_path_or_none(
|
"back_shiny_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "diamond-pearl/back/shiny/female/",
|
||||||
gen_iv.format(
|
info, 'png',
|
||||||
"diamond-pearl/back/shiny/female/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
"heartgold-soulsilver": {
|
"heartgold-soulsilver": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "heartgold-soulsilver/",
|
||||||
gen_iv.format("heartgold-soulsilver/" + file_name_png)
|
info, 'png',
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_female": file_path_or_none(
|
"front_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "heartgold-soulsilver/female/",
|
||||||
gen_iv.format(
|
info, 'png',
|
||||||
"heartgold-soulsilver/female/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny": file_path_or_none(
|
"front_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "heartgold-soulsilver/shiny/",
|
||||||
gen_iv.format(
|
info, 'png',
|
||||||
"heartgold-soulsilver/shiny/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny_female": file_path_or_none(
|
"front_shiny_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites
|
||||||
gen_iv.format(
|
+ gen_iv
|
||||||
"heartgold-soulsilver/shiny/female/" + file_name_png
|
+ "heartgold-soulsilver/shiny/female/",
|
||||||
)
|
info, 'png',
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_default": file_path_or_none(
|
"back_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "heartgold-soulsilver/back/",
|
||||||
gen_iv.format(
|
info, 'png',
|
||||||
"heartgold-soulsilver/back/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_female": file_path_or_none(
|
"back_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "heartgold-soulsilver/back/female/",
|
||||||
gen_iv.format(
|
info, 'png',
|
||||||
"heartgold-soulsilver/back/female/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_shiny": file_path_or_none(
|
"back_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "heartgold-soulsilver/back/shiny/",
|
||||||
gen_iv.format(
|
info, 'png',
|
||||||
"heartgold-soulsilver/back/shiny/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_shiny_female": file_path_or_none(
|
"back_shiny_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites
|
||||||
gen_iv.format(
|
+ gen_iv
|
||||||
"heartgold-soulsilver/back/shiny/female/"
|
+ "heartgold-soulsilver/back/shiny/female/",
|
||||||
+ file_name_png
|
info, 'png',
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
"platinum": {
|
"platinum": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "platinum/", info, 'png'
|
||||||
gen_iv.format("platinum/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_female": file_path_or_none(
|
"front_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "platinum/female/", info, 'png'
|
||||||
gen_iv.format("platinum/female/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny": file_path_or_none(
|
"front_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "platinum/shiny/", info, 'png'
|
||||||
gen_iv.format("platinum/shiny/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny_female": file_path_or_none(
|
"front_shiny_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "platinum/shiny/female/",
|
||||||
gen_iv.format("platinum/shiny/female/" + file_name_png)
|
info, 'png',
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_default": file_path_or_none(
|
"back_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "platinum/back/", info, 'png'
|
||||||
gen_iv.format("platinum/back/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_female": file_path_or_none(
|
"back_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "platinum/back/female/",
|
||||||
gen_iv.format("platinum/back/female/" + file_name_png)
|
info, 'png',
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_shiny": file_path_or_none(
|
"back_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "platinum/back/shiny/",
|
||||||
gen_iv.format("platinum/back/shiny/" + file_name_png)
|
info, 'png',
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_shiny_female": file_path_or_none(
|
"back_shiny_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_iv + "platinum/back/shiny/female/",
|
||||||
gen_iv.format(
|
info, 'png',
|
||||||
"platinum/back/shiny/female/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"generation-v": {
|
"generation-v": {
|
||||||
"black-white": {
|
"black-white": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_v + "black-white/", info, 'png'
|
||||||
gen_v.format("black-white/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_female": file_path_or_none(
|
"front_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_v + "black-white/female/", info, 'png'
|
||||||
gen_v.format("black-white/female/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny": file_path_or_none(
|
"front_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_v + "black-white/shiny/", info, 'png'
|
||||||
gen_v.format("black-white/shiny/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny_female": file_path_or_none(
|
"front_shiny_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_v + "black-white/shiny/female/",
|
||||||
gen_v.format(
|
info, 'png',
|
||||||
"black-white/shiny/female/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_default": file_path_or_none(
|
"back_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_v + "black-white/back/", info, 'png'
|
||||||
gen_v.format("black-white/back/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_female": file_path_or_none(
|
"back_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_v + "black-white/back/female/",
|
||||||
gen_v.format("black-white/back/female/" + file_name_png)
|
info, 'png',
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_shiny": file_path_or_none(
|
"back_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_v + "black-white/back/shiny/",
|
||||||
gen_v.format("black-white/back/shiny/" + file_name_png)
|
info, 'png',
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_shiny_female": file_path_or_none(
|
"back_shiny_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_v + "black-white/back/shiny/female/",
|
||||||
gen_v.format(
|
info, 'png',
|
||||||
"black-white/back/shiny/female/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"animated": {
|
"animated": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_v + "black-white/animated/",
|
||||||
gen_v.format(
|
info, 'gif',
|
||||||
"black-white/animated/" + file_name_gif
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_female": file_path_or_none(
|
"front_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_v + "black-white/animated/female/",
|
||||||
gen_v.format(
|
info, 'gif',
|
||||||
"black-white/animated/female/" + file_name_gif
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny": file_path_or_none(
|
"front_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_v + "black-white/animated/shiny/",
|
||||||
gen_v.format(
|
info, 'gif',
|
||||||
"black-white/animated/shiny/" + file_name_gif
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny_female": file_path_or_none(
|
"front_shiny_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites
|
||||||
gen_v.format(
|
+ gen_v
|
||||||
"black-white/animated/shiny/female/"
|
+ "black-white/animated/shiny/female/"
|
||||||
+ file_name_gif
|
, info, 'gif'
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_default": file_path_or_none(
|
"back_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_v + "black-white/animated/back/",
|
||||||
gen_v.format(
|
info, 'gif',
|
||||||
"black-white/animated/back/" + file_name_gif
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_female": file_path_or_none(
|
"back_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites
|
||||||
gen_v.format(
|
+ gen_v
|
||||||
"black-white/animated/back/female/"
|
+ "black-white/animated/back/female/"
|
||||||
+ file_name_gif
|
, info, 'gif'
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_shiny": file_path_or_none(
|
"back_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites
|
||||||
gen_v.format(
|
+ gen_v
|
||||||
"black-white/animated/back/shiny/"
|
+ "black-white/animated/back/shiny/"
|
||||||
+ file_name_gif
|
, info, 'gif'
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"back_shiny_female": file_path_or_none(
|
"back_shiny_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites
|
||||||
gen_v.format(
|
+ gen_v
|
||||||
"black-white/animated/back/shiny/female/"
|
+ "black-white/animated/back/shiny/female/"
|
||||||
+ file_name_gif
|
, info, 'gif'
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"generation-vi": {
|
"generation-vi": {
|
||||||
"omegaruby-alphasapphire": {
|
"omegaruby-alphasapphire": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_vi + "omegaruby-alphasapphire/",
|
||||||
gen_vi.format(
|
info, 'png',
|
||||||
"omegaruby-alphasapphire/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_female": file_path_or_none(
|
"front_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_vi + "omegaruby-alphasapphire/female/",
|
||||||
gen_vi.format(
|
info, 'png',
|
||||||
"omegaruby-alphasapphire/female/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny": file_path_or_none(
|
"front_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_vi + "omegaruby-alphasapphire/shiny/",
|
||||||
gen_vi.format(
|
info, 'png',
|
||||||
"omegaruby-alphasapphire/shiny/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny_female": file_path_or_none(
|
"front_shiny_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites
|
||||||
gen_vi.format(
|
+ gen_vi
|
||||||
"omegaruby-alphasapphire/shiny/female/"
|
+ "omegaruby-alphasapphire/shiny/female/",
|
||||||
+ file_name_png
|
info, 'png',
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
"x-y": {
|
"x-y": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(gen_vi.format("x-y/" + file_name_png))
|
poke_sprites + gen_vi + "x-y/", info, 'png'
|
||||||
),
|
),
|
||||||
"front_female": file_path_or_none(
|
"front_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_vi + "x-y/female/", info, 'png'
|
||||||
gen_vi.format("x-y/female/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny": file_path_or_none(
|
"front_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_vi + "x-y/shiny/", info, 'png'
|
||||||
gen_vi.format("x-y/shiny/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny_female": file_path_or_none(
|
"front_shiny_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_vi + "x-y/shiny/female/", info, 'png'
|
||||||
gen_vi.format("x-y/shiny/female/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"generation-vii": {
|
"generation-vii": {
|
||||||
"ultra-sun-ultra-moon": {
|
"ultra-sun-ultra-moon": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_vii + "ultra-sun-ultra-moon/",
|
||||||
gen_vii.format("ultra-sun-ultra-moon/" + file_name_png)
|
info, 'png',
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_female": file_path_or_none(
|
"front_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_vii + "ultra-sun-ultra-moon/female/",
|
||||||
gen_vii.format(
|
info, 'png',
|
||||||
"ultra-sun-ultra-moon/female/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny": file_path_or_none(
|
"front_shiny": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_vii + "ultra-sun-ultra-moon/shiny/",
|
||||||
gen_vii.format(
|
info, 'png',
|
||||||
"ultra-sun-ultra-moon/shiny/" + file_name_png
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_shiny_female": file_path_or_none(
|
"front_shiny_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites
|
||||||
gen_vii.format(
|
+ gen_vii
|
||||||
"ultra-sun-ultra-moon/shiny/female/" + file_name_png
|
+ "ultra-sun-ultra-moon/shiny/female/",
|
||||||
)
|
info, 'png',
|
||||||
)
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
"icons": {
|
"icons": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_vii + "icons/", info, 'png'
|
||||||
gen_vii.format("icons/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_female": file_path_or_none(
|
"front_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_vii + "icons/female/", info, 'png'
|
||||||
gen_vii.format("icons/female/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"generation-viii": {
|
"generation-viii": {
|
||||||
"icons": {
|
"icons": {
|
||||||
"front_default": file_path_or_none(
|
"front_default": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_viii + "icons/", info, 'png'
|
||||||
gen_viii.format("icons/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"front_female": file_path_or_none(
|
"front_female": try_image_names(
|
||||||
poke_sprites.format(
|
poke_sprites + gen_viii + "icons/female/", info, 'png'
|
||||||
gen_viii.format("icons/female/" + file_name_png)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -2044,28 +1857,41 @@ def _build_pokemons():
|
||||||
|
|
||||||
build_generic((PokemonForm,), "pokemon_forms.csv", csv_record_to_objects)
|
build_generic((PokemonForm,), "pokemon_forms.csv", csv_record_to_objects)
|
||||||
|
|
||||||
def csv_record_to_objects(info):
|
def try_image_names(path, info, extension):
|
||||||
pokemon = Pokemon.objects.get(pk=int(info[3]))
|
form_identifier = info[2]
|
||||||
poke_sprites = "pokemon/{0}"
|
pokemon_id = info[3]
|
||||||
if info[2]:
|
pokemon = Pokemon.objects.get(pk=int(pokemon_id))
|
||||||
file_name_str = "%s-%s.png" % (
|
species_id = getattr(pokemon, "pokemon_species_id")
|
||||||
getattr(pokemon, "pokemon_species_id"),
|
if form_identifier:
|
||||||
info[2],
|
file_name_str = "%s-%s.%s" % (
|
||||||
|
species_id,
|
||||||
|
form_identifier,
|
||||||
|
extension
|
||||||
)
|
)
|
||||||
file_name_int = "%s.png" % info[3]
|
file_name_int = "%s.%s" % (pokemon_id, extension)
|
||||||
file_name = (
|
file_name = (
|
||||||
file_name_str
|
file_name_int
|
||||||
if file_path_or_none(poke_sprites.format(file_name_str))
|
if file_path_or_none(path + file_name_int)
|
||||||
else file_name_int
|
else file_name_str
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
file_name = "%s.png" % getattr(pokemon, "pokemon_species_id")
|
file_name = "%s.%s" % (species_id, extension)
|
||||||
|
return file_path_or_none(path + file_name)
|
||||||
|
|
||||||
|
def csv_record_to_objects(info):
|
||||||
|
poke_sprites = "pokemon/"
|
||||||
sprites = {
|
sprites = {
|
||||||
"front_default": file_path_or_none(poke_sprites.format(file_name)),
|
"front_default": try_image_names(poke_sprites, info, 'png'),
|
||||||
"front_shiny": file_path_or_none(poke_sprites.format("shiny/" + file_name)),
|
"front_shiny": try_image_names(poke_sprites + "shiny/", info, 'png'),
|
||||||
"back_default": file_path_or_none(poke_sprites.format("back/" + file_name)),
|
"back_default": try_image_names(poke_sprites + "back/", info, 'png'),
|
||||||
"back_shiny": file_path_or_none(
|
"back_shiny": try_image_names(poke_sprites + "back/shiny/", info, 'png'),
|
||||||
poke_sprites.format("back/shiny/" + file_name)
|
"front_female": try_image_names(poke_sprites + "female/", info, "png"),
|
||||||
|
"front_shiny_female": try_image_names(
|
||||||
|
poke_sprites + "shiny/female/", info, "png"
|
||||||
|
),
|
||||||
|
"back_female": try_image_names(poke_sprites + "back/female/", info, "png"),
|
||||||
|
"back_shiny_female": try_image_names(
|
||||||
|
poke_sprites + "back/shiny/female/", info, "png"
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
yield PokemonFormSprites(
|
yield PokemonFormSprites(
|
||||||
|
|
Loading…
Reference in a new issue