-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb2html.py
More file actions
executable file
·37 lines (33 loc) · 1.2 KB
/
db2html.py
File metadata and controls
executable file
·37 lines (33 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
import sqlite3, markdown2
spell_tags = ['schools', 'sphere', 'range', 'components', 'duration', 'casting_time', 'area_of_effect', 'saving_throw', 'reversible', 'src']
spell_divtags = ['class', 'level'] + spell_tags
spell_tagnames = {
'class': 'Class',
'title': 'Title',
'level': 'Level',
'schools': 'Schools',
'sphere': 'Sphere',
'range': 'Range',
'components': 'Components',
'duration': 'Duration',
'casting_time': 'Casting Time',
'area_of_effect': 'Area of Effect',
'saving_throw': 'Saving Throw',
'reversible': 'Reversible',
'src': 'Source',
}
db = sqlite3.connect('2e.sqlite3')
db.row_factory = sqlite3.Row
print('<html><head><title>2E Spells</title></head><body>')
for row in db.execute('select * from spells order by class, level, name'):
print('<div')
for tag in spell_divtags:
print(' %s="%s"' % (tag, row[tag]))
print('>')
print('<h5>%s (%s Level %s)</h5>' % (row['name'], row['class'], row['level']))
for tag in spell_tags:
print('<em>%s:</em> %s' % (spell_tagnames[tag], row[tag]))
print(markdown2.markdown(row['txt'], extras=['tables', 'header-ids']))
print('</div>')
print('</body></html>')