# Also fetch the current suffix table list current_pokemon_suffix_list = c.execute( "select * from pokemon_suffix").fetchall() print(current_pokemon_suffix_list) # Build list of pokemon with dashes in their name that fit the profile mentioned above dashpokemonlist = list() for pokemon in pokemon_unique_list: #Step 1 check if name has dash if "-" in pokemon[1]: #Step 2 find nationalID of the corresponding uniqueID # Only 1 instance will be returned, to access get the 0 position of the list, # Nat ID is in the 1 pos nationalID = function_pokemonID.returnPokemonNationalIDFromUniqueID( pokemon[0], c)[0][1] #Step 3, use nationalID to find how many uniqueID's are returned uniqueIDlist = function_pokemonID.returnPokemonUniqueIDFromNationalID( nationalID, c) #Step 4, if the size of list is bigger than 1, and the uniqueID is not already in the list # than we can safely add to the dashpokemonlist if len(uniqueIDlist) > 1: pokemonAlreadyPresent = False for suffix in current_pokemon_suffix_list: if pokemon[0] == suffix[0]: pokemonAlreadyPresent = True if not pokemonAlreadyPresent: dashpokemonlist.append(pokemon)
pokemon_unique_list = c.execute("select * from pokemon_unique_info").fetchall() # Also fetch the current suffix table list current_pokemon_suffix_list = c.execute("select * from pokemon_suffix").fetchall() print(current_pokemon_suffix_list) # Build list of pokemon with dashes in their name that fit the profile mentioned above dashpokemonlist = list() for pokemon in pokemon_unique_list: #Step 1 check if name has dash if "-" in pokemon[1]: #Step 2 find nationalID of the corresponding uniqueID # Only 1 instance will be returned, to access get the 0 position of the list, # Nat ID is in the 1 pos nationalID = function_pokemonID.returnPokemonNationalIDFromUniqueID(pokemon[0], c)[0][1] #Step 3, use nationalID to find how many uniqueID's are returned uniqueIDlist = function_pokemonID.returnPokemonUniqueIDFromNationalID(nationalID, c) #Step 4, if the size of list is bigger than 1, and the uniqueID is not already in the list # than we can safely add to the dashpokemonlist if len(uniqueIDlist) > 1: pokemonAlreadyPresent = False for suffix in current_pokemon_suffix_list: if pokemon[0] == suffix[0]: pokemonAlreadyPresent = True if not pokemonAlreadyPresent: dashpokemonlist.append(pokemon) print(dashpokemonlist)
evolutionlist = pokemons["evos"] # Need to make sure these are not alternatives for evocount, evo in enumerate(evolutionlist): method = "" evolutionIDlist = function_pokemonID.returnPokemonUniqueIDFromName(evo, c) # If evolutionIDlist is an empty set, then since the name doesn't correspond to what the database has, must # be an alt form and we can ignore # If it returns something, then the first position in the list is the pokemon # first position there again is the id if len(evolutionIDlist) > 0: # Use this to obtain evolution information from serebii # Returns list, should be only 1 though, position 1 of position 0 corresponds to nationalID nationalID = function_pokemonID.returnPokemonNationalIDFromUniqueID(uniqueID, c)[0][1] # Format to 3 digit form nationalID = "%03d" % nationalID # Create URL and access serebiiURL = serebiiURLstart+nationalID+serebiiURLend serebiiPokedex = urllib.request.urlopen(serebiiURL) inputData = serebiiPokedex.read() soup = BeautifulSoup(inputData, "html.parser") # Find main table that contains evolution information maintable = soup.find( attrs={"class": "evochain"}) # Construct the image url, pokemonimageURL = "/xy/pokemon/"+nationalID+".png"