Add Sun dex entries

Note: there are dex entries for forms too, but this only adds the text
for the default form because the db schema assumes dex entries are
per-species.
This commit is contained in:
Andrew Ekstedt 2020-06-23 00:48:33 -07:00
parent b05ff3a5b1
commit 5fe8fdcc95
2 changed files with 8925 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,52 @@
# Generates SQL to add flavor text from the text dump to the database.
#
# Usage: python add-sm-flavortext.py path/to/text | psql pokedex
import os.path
import sys
import re
textdir = sys.argv[1]
VERSION = 'sun'
FILE = '119'
NUM_SPECIES = 807
lang_idents = {
'ja-kana': 'ja-Hrkt',
'ja-kanji': 'ja',
}
flavor_texts = []
for lang in 'ja-kana', 'ja-kanji', 'en', 'fr', 'it', 'de', 'es', 'ko', 'zh-Hant', 'zh-Hans':
f = open(os.path.join(textdir, lang, FILE))
flavor_texts.append((lang_idents.get(lang, lang), f))
print("BEGIN;")
for lang, text in flavor_texts:
print("\echo '%s'" % lang)
print("WITH lang AS (SELECT id FROM languages WHERE identifier = '%s')," % lang)
print(" version AS (SELECT id FROM versions WHERE identifier = '%s')" % VERSION)
print("INSERT INTO pokemon_species_flavor_text (species_id, version_id, language_id, flavor_text) VALUES");
first = True
for i, line in enumerate(text):
if i == 0:
continue
if i > NUM_SPECIES:
break
if line == '\n':
continue
line = line.strip('\n')
line = line.replace("\\ue07f", "\\u202f") # nbsp
if '\\x' in line or '\\r' in line or '\\u' in line.replace("\\u202f",""):
print("warning: %s %d: %r" % (lang, i, line), file=sys.stderr)
if first:
first = False
else:
print(",\n", end="")
print(" (%d, (select id from version), (select id from lang), E'%s')" % (i, line), end="")
print(";")
print("COMMIT;")
#print("ROLLBACK;")