parameters: ()
return_statement: return places, fishes, placefish
docstring: Returns dictionaries for places, fish, and place->fish mapping
docstring_summary: Returns dictionaries for places, fish, and place->fish mapping
docstring_tokens: Returns dictionaries for places fish and place - > fish mapping
function: def get_fish_data():
      """Returns dictionaries for places, fish, and place->fish mapping"""
      # Generate the columns needed
      columns = ["ID", "PlaceName.ID"]
  
      for locale in locales:
          columns.append(f"PlaceName.Name_{locale}")
          columns.append(f"PlaceName.NameNoArticle_{locale}")
  
      for i in range(10):
          for locale in locales:
              columns.append(f"Item{i}.ID")
              columns.append(f"Item{i}.Singular_{locale}")
              columns.append(f"Item{i}.Plural_{locale}")
  
      results = xivapi("FishingSpot", {"columns": columns})
  
      # Build the data dicts from results
      places = {}
      fishes = {}
      placefish = {}
  
      for locale in locales:
          places[locale] = {}
          fishes[locale] = {}
  
      for result in results:
          # Skip spots without place names
          if not result["PlaceName"]["Name_en"]:
              continue
  
          for locale in locales:
              place_id = result["PlaceName"]["ID"]
  
              if locale == "fr":
                  # This is to specifically to turn `Arbre à pappus` into `L'arbre à pappus`.
                  # Other French names already have `L'` in the front, so we can't treat it
                  # as optional in the regex.  See: #2651.
                  places[locale][place_id] = result["PlaceName"][f"Name_{locale}"]
              else:
                  # However, English specifically is much more inconsistent about when "The"
                  # appears in the Name_en field.  "Limsa Lominsa lower decks" has a "The" in
                  # game, but not in Name_en.  "The Source" has a "The" in game, but does have
                  # one in Name_en.  Prefering NameNoArticle_en removes all "Thes" from English.
  
                  # Occasionally, PlaceName data will have null or empty strings in the NameNoArticle field.
                  # In these instances, I believe it simply defaults to the Name attribute.
                  places[locale][place_id] = (
                      result["PlaceName"][f"NameNoArticle_{locale}"]
                      or result["PlaceName"][f"Name_{locale}"]
                  )
  
              id_list = []
  
              for item in range(10):
                  fish = result[f"Item{item}"]
  
                  # Skip if no name
                  if not fish[f"Singular_{locale}"]:
                      continue
  
                  if locale == "de":
                      fish["Singular_de"] = cleanup_german(fish["Singular_de"])
                      fish["Plural_de"] = cleanup_german(fish["Plural_de"])
                      flist = fish["Singular_de"]
                      flist.extend(fish["Plural_de"])
                  else:
                      flist = [fish[f"Singular_{locale}"], fish[f"Plural_{locale}"]]
  
                  # uniq
                  flist = [x for idx, x in enumerate(flist) if idx == flist.index(x) and x]
                  # delistify if only one element
                  if len(flist) == 1:
                      flist = flist[0]
  
                  fishes[locale][fish["ID"]] = flist
  
                  # Add fish to id list
                  id_list.append(fish["ID"])
  
              if place_id in placefish:
                  # not efficient to do this, but number of fish is small
                  placefish[place_id] = sorted(list(set(placefish[place_id]).union(set(id_list))))
              else:
                  placefish[place_id] = sorted(id_list)
  
      return places, fishes, placefish
function_tokens: def get_fish_data ( ) : # Generate the columns needed columns = [ "ID" , "PlaceName.ID" ] for locale in locales : columns . append ( f"PlaceName.Name_{locale}" ) columns . append ( f"PlaceName.NameNoArticle_{locale}" ) for i in range ( 10 ) : for locale in locales : columns . append ( f"Item{i}.ID" ) columns . append ( f"Item{i}.Singular_{locale}" ) columns . append ( f"Item{i}.Plural_{locale}" ) results = xivapi ( "FishingSpot" , { "columns" : columns } ) # Build the data dicts from results places = { } fishes = { } placefish = { } for locale in locales : places [ locale ] = { } fishes [ locale ] = { } for result in results : # Skip spots without place names if not result [ "PlaceName" ] [ "Name_en" ] : continue for locale in locales : place_id = result [ "PlaceName" ] [ "ID" ] if locale == "fr" : # This is to specifically to turn `Arbre à pappus` into `L'arbre à pappus`. # Other French names already have `L'` in the front, so we can't treat it # as optional in the regex.  See: #2651. places [ locale ] [ place_id ] = result [ "PlaceName" ] [ f"Name_{locale}" ] else : # However, English specifically is much more inconsistent about when "The" # appears in the Name_en field.  "Limsa Lominsa lower decks" has a "The" in # game, but not in Name_en.  "The Source" has a "The" in game, but does have # one in Name_en.  Prefering NameNoArticle_en removes all "Thes" from English. # Occasionally, PlaceName data will have null or empty strings in the NameNoArticle field. # In these instances, I believe it simply defaults to the Name attribute. places [ locale ] [ place_id ] = ( result [ "PlaceName" ] [ f"NameNoArticle_{locale}" ] or result [ "PlaceName" ] [ f"Name_{locale}" ] ) id_list = [ ] for item in range ( 10 ) : fish = result [ f"Item{item}" ] # Skip if no name if not fish [ f"Singular_{locale}" ] : continue if locale == "de" : fish [ "Singular_de" ] = cleanup_german ( fish [ "Singular_de" ] ) fish [ "Plural_de" ] = cleanup_german ( fish [ "Plural_de" ] ) flist = fish [ "Singular_de" ] flist . extend ( fish [ "Plural_de" ] ) else : flist = [ fish [ f"Singular_{locale}" ] , fish [ f"Plural_{locale}" ] ] # uniq flist = [ x for idx , x in enumerate ( flist ) if idx == flist . index ( x ) and x ] # delistify if only one element if len ( flist ) == 1 : flist = flist [ 0 ] fishes [ locale ] [ fish [ "ID" ] ] = flist # Add fish to id list id_list . append ( fish [ "ID" ] ) if place_id in placefish : # not efficient to do this, but number of fish is small placefish [ place_id ] = sorted ( list ( set ( placefish [ place_id ] ) . union ( set ( id_list ) ) ) ) else : placefish [ place_id ] = sorted ( id_list ) return places , fishes , placefish