From 6ea4c4b52fe8fd1f002ae260aeffba5fa72e9f8f Mon Sep 17 00:00:00 2001 From: Quildra Date: Tue, 1 Oct 2024 07:10:34 +0100 Subject: [PATCH] - More small improvments to the parser --- Utilities/DetermineOriginGame.py | 16 +++++++++------- pokemon_home_list.csv | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Utilities/DetermineOriginGame.py b/Utilities/DetermineOriginGame.py index 7a5fd88..e67bb9c 100644 --- a/Utilities/DetermineOriginGame.py +++ b/Utilities/DetermineOriginGame.py @@ -348,7 +348,7 @@ def get_locations_from_bulbapedia(pokemon_name, form, cache): variant = "" for sibling in event_header.find_next_siblings(): - if sibling.name == 'h4': + if sibling.name == 'h4' or "held" in sibling.getText(strip=True).lower(): break if sibling.name == 'h5': variant = sibling.get_text(strip=True) @@ -376,7 +376,7 @@ def get_locations_from_bulbapedia(pokemon_name, form, cache): # For Later for variant in event_tables: - if variant == pokemon_name or (form and form in variant): + if (variant == pokemon_name and form is None)or (form and form in variant): games_container_rows = event_tables[variant].find_all('tr') for game_row in games_container_rows: entries = game_row.find_all('td') @@ -384,7 +384,9 @@ def get_locations_from_bulbapedia(pokemon_name, form, cache): games_string = entries[0].find('a').get('title') for game in all_games: if game in games_string: - game_locations[game] = "Event" + if game not in game_locations: + game_locations[game] = [] + game_locations[game].append("Event") return game_locations @@ -620,9 +622,9 @@ def check_alternative_sources(pokemon, cache): if event_status: return "Event", "Event" - bulb_locations = get_locations_from_bulbapedia(pokemon['base_name'], pokemon['form'], cache) - if bulb_locations: - return bulb_locations[0], "Bulbapedia" + #bulb_locations = get_locations_from_bulbapedia(pokemon['base_name'], pokemon['form'], cache) + #if bulb_locations: + # return bulb_locations[0], "Bulbapedia" # Check generation introduced #generation = species_data.get('generation', {}).get('name', '') @@ -649,7 +651,7 @@ def handle_unknown_encounters(pokemon_list, cache): if __name__ == "__main__": get_cached_data() - pokemon_list = read_pokemon_list('pokemon_home_list.csv', limit=151) + pokemon_list = read_pokemon_list('pokemon_home_list.csv', limit=3000) pokemon_list_with_games = determine_earliest_games(pokemon_list, cache) pokemon_list_adjusted = adjust_for_evolution(pokemon_list_with_games, cache) pokemon_list_with_locations = add_encounter_locations(pokemon_list_adjusted, cache) diff --git a/pokemon_home_list.csv b/pokemon_home_list.csv index 16bc897..c8c6083 100644 --- a/pokemon_home_list.csv +++ b/pokemon_home_list.csv @@ -40,10 +40,10 @@ number,name 0027,Sandshrew (Alolan Form) 0028,Sandslash 0028,Sandslash (Alolan Form) -0029,Nidoran-f +0029,Nidoran♀ 0030,Nidorina 0031,Nidoqueen -0032,Nidoran-m +0032,Nidoran♂ 0033,Nidorino 0034,Nidoking 0035,Clefairy