mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Add script for adding B/W locations
in the hope that it will be useful in future generations.
This commit is contained in:
parent
7b7c0addde
commit
03813bd765
1 changed files with 49 additions and 0 deletions
49
scripts/add-bw-locations.py
Executable file
49
scripts/add-bw-locations.py
Executable file
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env python2
|
||||
|
||||
from codecs import open
|
||||
|
||||
from pokedex.db import connect, identifier_from_name
|
||||
from pokedex.db.tables import Language
|
||||
from pokedex.db.tables import Location, LocationGameIndex
|
||||
|
||||
session = connect()
|
||||
|
||||
en = session.query(Language).filter_by(identifier='en').one() # English
|
||||
ja = session.query(Language).filter_by(identifier='ja').one() # Japanese
|
||||
|
||||
with open("bw-location-names-en", "r", "utf-8") as f:
|
||||
en_names = [line.rstrip("\n") for line in f]
|
||||
with open("bw-location-names-kanji", "r", "utf-8") as f:
|
||||
ja_names = [line.rstrip("\n") for line in f]
|
||||
|
||||
locations = {}
|
||||
for i, name in enumerate(zip(en_names, ja_names)):
|
||||
if i == 0:
|
||||
continue
|
||||
|
||||
en_name, ja_name = name
|
||||
if not en_name:
|
||||
continue
|
||||
|
||||
if name in locations:
|
||||
loc = locations[name]
|
||||
else:
|
||||
loc = Location()
|
||||
if en_name:
|
||||
loc.name_map[en] = en_name
|
||||
if ja_name:
|
||||
loc.name_map[ja] = ja_name
|
||||
loc.region_id = 5 # Unova
|
||||
loc.identifier = identifier_from_name(en_name)
|
||||
|
||||
locations[name] = loc
|
||||
|
||||
lgi = LocationGameIndex()
|
||||
lgi.location = loc
|
||||
lgi.generation_id = 5 # Gen 5
|
||||
lgi.game_index = i
|
||||
|
||||
session.add(loc)
|
||||
session.add(lgi)
|
||||
|
||||
session.commit()
|
Loading…
Reference in a new issue