ammo sql -> yaml implemented; related to #59
parent
a3ae931bb3
commit
798aa87602
|
@ -0,0 +1,43 @@
|
||||||
|
ammunition:
|
||||||
|
- amount: 10
|
||||||
|
bulk: 0.1
|
||||||
|
descr: These projectiles are the ammunition for bows. The shaft of an arrow is made
|
||||||
|
of wood. It is stabilized in flight by fletching at one end and bears a metal
|
||||||
|
head on the other.
|
||||||
|
name: Arrows
|
||||||
|
price_gp: 0.1
|
||||||
|
source:
|
||||||
|
- abbr: CRB
|
||||||
|
page_start: 282
|
||||||
|
page_stop: 282
|
||||||
|
- amount: 10
|
||||||
|
bulk: 0.1
|
||||||
|
descr: These thin, light darts are typically made of hardwood and stabilized with
|
||||||
|
fletching of down or fur. They are often hollow so they can be used to deliver
|
||||||
|
poison.
|
||||||
|
name: Blowgun Darts
|
||||||
|
price_gp: 0.05
|
||||||
|
source:
|
||||||
|
- abbr: CRB
|
||||||
|
page_start: 281
|
||||||
|
page_stop: 281
|
||||||
|
- amount: 10
|
||||||
|
bulk: 0.1
|
||||||
|
descr: Shorter than traditional arrows but similar in construction, bolts are the
|
||||||
|
ammunition used by crossbows.
|
||||||
|
name: Bolts
|
||||||
|
price_gp: 0.1
|
||||||
|
source:
|
||||||
|
- abbr: CRB
|
||||||
|
page_start: 281
|
||||||
|
page_stop: 281
|
||||||
|
- amount: 10
|
||||||
|
bulk: 0.1
|
||||||
|
descr: These are small metal balls, typically either iron or lead, designed to be
|
||||||
|
used as ammunition in slings.
|
||||||
|
name: Sling Bullets
|
||||||
|
price_gp: 0.01
|
||||||
|
source:
|
||||||
|
- abbr: CRB
|
||||||
|
page_start: 281
|
||||||
|
page_stop: 281
|
|
@ -0,0 +1,50 @@
|
||||||
|
import sqlite3
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
conn = sqlite3.connect('../../pf2.db')
|
||||||
|
|
||||||
|
conn.row_factory = sqlite3.Row
|
||||||
|
c = conn.cursor()
|
||||||
|
c.execute("select * from ammunition;")
|
||||||
|
res = [dict(row) for row in c.fetchall()]
|
||||||
|
|
||||||
|
# for i in res:
|
||||||
|
# print(i)
|
||||||
|
|
||||||
|
reslist = []
|
||||||
|
for i in res:
|
||||||
|
tmp = {
|
||||||
|
"name":
|
||||||
|
i['name'],
|
||||||
|
"price_gp":
|
||||||
|
i['price_gp'],
|
||||||
|
"amount":
|
||||||
|
i['amount'],
|
||||||
|
"bulk":
|
||||||
|
i['bulk'],
|
||||||
|
"descr":
|
||||||
|
i['descr'],
|
||||||
|
"source": [
|
||||||
|
{
|
||||||
|
'abbr': 'CRB',
|
||||||
|
'page_start': int(i['sources_pages']),
|
||||||
|
'page_stop': int(i['sources_pages'])
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
reslist.append(tmp)
|
||||||
|
|
||||||
|
# print(reslist)
|
||||||
|
|
||||||
|
tmpd = {'ammunition': reslist}
|
||||||
|
|
||||||
|
# now dump to yaml
|
||||||
|
final = yaml.safe_dump(tmpd, allow_unicode=True)
|
||||||
|
with open('tmp-ammo.yaml', 'w') as f:
|
||||||
|
f.write(final)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Loading…
Reference in New Issue