forked from Soyweiser/CDDA-Wiki-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
speciesfears.py
46 lines (40 loc) · 1.77 KB
/
speciesfears.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
42
43
44
45
46
import json
from version import version
import pywikibot
#data is uploaded automatically, used for the Template:Speciesfears
with open('data/json/species.json') as data_file:
data = json.load(data_file)
header ='''<includeonly>{{#switch:{{lc:{{{1}}}}}
|none
|species_none =error speciesfears not set for: {{{1|none}}}\n'''
footer = ''' |#default={{{1|none}}}
}}</includeonly><noinclude>
Automatically generated by [https://github.com/Soyweiser/CDDA-Wiki-Scripts The speciesfears.py script]. Any edits made to this can and will be overwritten. Please contact [[User:Soyweiser|Soyweiser]] if you want make changes to this page. Especially as any changes made here probably also means there have been changes in other pages. And there are tools to update those a little bit quicker.\n\n
Template for display fear triggers associated with a species.\n'''
footer += version+'''[[Category:Templates]]
</noinclude>'''
output = [ "" ]
output.append(header)
for it in range(0, len(data)):
output.append(" |")
output.append(data[it]['id'].lower())
output.append(" = ")
if('fear_triggers' in data[it]): #fear_triggers
for ite in range(0, len(data[it]['fear_triggers'])):
if(ite > 0):
output.append(", ")
output.append("{{efears")
output.append(data[it]['fear_triggers'][ite])
output.append("}}\n")
else:
output.append("nothing in particular\n")
output.append(data[it]['name'])
output.append("\n")
output.append(footer)
text = "".join(output)
text.replace("\n", "\\n")
site = pywikibot.Site('en', 'cddawiki')
page = pywikibot.Page(site, 'Template:Speciesfears')
page.text = text
page.save('Updated text automatically via the https://github.com/Soyweiser/CDDA-Wiki-Scripts speciesfears.py script')
exit()