-convert price_gp to price_cp in weapons
parent
00685eb77c
commit
ee57fd402a
|
@ -3,6 +3,7 @@ import yaml
|
|||
import pprint
|
||||
|
||||
def main():
|
||||
pp = pprint.PrettyPrinter(indent=2)
|
||||
conn = sqlite3.connect('../../pf2.db')
|
||||
conn.row_factory = sqlite3.Row
|
||||
|
||||
|
@ -23,7 +24,22 @@ def main():
|
|||
c = conn.cursor()
|
||||
c.execute(q)
|
||||
data = [dict(row) for row in c.fetchall()]
|
||||
pprint.pprint(data)
|
||||
for i in data:
|
||||
# handle empty bulk entries
|
||||
if i['bulk'] == '':
|
||||
i['bulk'] = '-'
|
||||
# convert gp prices to cp prices to avoid float issues
|
||||
if i['price_gp'] == '':
|
||||
i['price_gp'] = '0'
|
||||
i['price_cp'] = int(float(i['price_gp']) * 100)
|
||||
del i['price_gp']
|
||||
|
||||
pp.pprint(data)
|
||||
|
||||
fdata = {'weapons': data}
|
||||
final = yaml.safe_dump(fdata, allow_unicode=True)
|
||||
with open('tmp-weapons.yaml', 'w') as f:
|
||||
f.write(final)
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue