forked from RheingoldRiver/sorcerer-update
-
Notifications
You must be signed in to change notification settings - Fork 1
/
createMiscItems.py
41 lines (35 loc) · 1.11 KB
/
createMiscItems.py
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
38
39
40
41
import json
import string
from mwcleric import AuthCredentials
from mwcleric import WikiggClient
WIKITEXT = """{{{{MiscItem Infobox
|Type={Type}
|Description={Description}
|Lore={Lore}
|Stash={Stash}
|Purchasable={Purchasable}
|Price={Price}
|Worth={Worth}
}}}}"""
class Creator:
def __init__(self):
credentials = AuthCredentials(user_file="me")
self.site = WikiggClient('witchfire', credentials=credentials)
#self.summary = 'Tabber -> Gallery'
with open('MiscItem.json', 'r', encoding='utf-8') as f:
self.data = json.load(f)
def run(self):
PAGETEXT = ''
for k, v in self.data.items():
self.site.client.pages[string.capwords(k)].save(WIKITEXT.format(
Type=v['Type'],
Description=v['Description'],
Lore=v['Lore'],
Stash=v['Stash'],
Purchasable=v['Purchasable'],
Price=v['Price'],
Worth=v['Worth']
))
self.site.client.pages['MiscItem Infobox'].save(PAGETEXT)
if __name__ == '__main__':
Creator().run()