Fix terrain2wiki.py for terrain.cfg syntax changes and add a note about terrain2wiki in terrain.cfg

This commit is contained in:
Thibault Févry 2015-03-28 17:14:34 +01:00
parent a1e66d6f2a
commit 2f31e98054
2 changed files with 13 additions and 6 deletions

View file

@ -7,6 +7,8 @@
# or "[topic] id=terrain_some_id" identifying its description in [help]
# NOTE: this list is sorted to group things comprehensibly in the editor
# NOTE: this data is parsed by data/tools/terrain2wiki.py yo generate
# the TerrainCodeTableWML wiki page.
#
# ## Water ##
@ -427,7 +429,7 @@ Most units receive 20 to 40% defense in sand."
[/terrain_type]
[terrain_type]
symbol_image="misc/brazier-embellishment"
symbol_image=misc/brazier-embellishment
id=brazier
editor_name= _ "Brazier"
string=^Eb
@ -436,7 +438,7 @@ Most units receive 20 to 40% defense in sand."
[/terrain_type]
[terrain_type]
symbol_image="misc/brazier-A01"
symbol_image=misc/brazier-A01
id=brazier-lit
editor_name= _ "Lit Brazier"
string=^Ebn

View file

@ -1,5 +1,5 @@
#!/usr/bin/python
#-*- coding:utf-8 -*-
# -*- coding:utf-8 -*-
"""
A script to create the "Terrain Table" on the TerrainCodeTableWML wiki page.
@ -57,6 +57,12 @@ def parse_terrain(data):
# directly. (They're only there to make aliasing work.)
if i[0].startswith(" "):
continue
# This avoids problems due to additional = in strings. Exact string
# removal does not matter as long as we do not print help_topic_text
# in the wiki page.
removeus = ("<italic>text='", "'</italic>", "<ref>dst='", "text='", "'</ref>")
for text in removeus:
i = [a.replace(text, "") for a in i]
# Create a dictionary of key and values
content = dict([v.strip().split("=") for v in i])
# Hidden things shouldn't be displayed
@ -90,13 +96,12 @@ dest='output_path', help="The location of the output file.")
path = args.path
output_path = args.output_path
if not os.path.exists(path) and not path.endswith('.cfg'):
print("Invalid path: '%s' does not exist") % path
if not os.path.exists(path) or not path.endswith('.cfg'):
print("Invalid path: '%s' does not exist or not a .cfg file.") % path
sys.exit(1)
with open(path, "r") as input_file:
data = input_file.read()
data = parse_terrain(data)
with open(output_path, "w") as output: