-convert price_gp to price_cp in weapons
parent
00685eb77c
commit
ee57fd402a
|
@ -3,6 +3,7 @@ import yaml
|
||||||
import pprint
|
import pprint
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
pp = pprint.PrettyPrinter(indent=2)
|
||||||
conn = sqlite3.connect('../../pf2.db')
|
conn = sqlite3.connect('../../pf2.db')
|
||||||
conn.row_factory = sqlite3.Row
|
conn.row_factory = sqlite3.Row
|
||||||
|
|
||||||
|
@ -23,9 +24,24 @@ def main():
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
c.execute(q)
|
c.execute(q)
|
||||||
data = [dict(row) for row in c.fetchall()]
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue