From 2f31e98054e1540b2ce5c8b4aafa18492704e564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20F=C3=A9vry?= Date: Sat, 28 Mar 2015 17:14:34 +0100 Subject: [PATCH] Fix terrain2wiki.py for terrain.cfg syntax changes and add a note about terrain2wiki in terrain.cfg --- data/core/terrain.cfg | 6 ++++-- data/tools/terrain2wiki.py | 13 +++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/data/core/terrain.cfg b/data/core/terrain.cfg index 5e5694a45e9..8c3cfcbab69 100644 --- a/data/core/terrain.cfg +++ b/data/core/terrain.cfg @@ -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 diff --git a/data/tools/terrain2wiki.py b/data/tools/terrain2wiki.py index b2523093402..99f3158d067 100755 --- a/data/tools/terrain2wiki.py +++ b/data/tools/terrain2wiki.py @@ -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 = ("text='", "'", "dst='", "text='", "'") + 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: