mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-19 05:29:02 +00:00
Fix terrain2wiki.py for terrain.cfg syntax changes and add a note about terrain2wiki in terrain.cfg
This commit is contained in:
parent
a1e66d6f2a
commit
2f31e98054
@ -7,6 +7,8 @@
|
|||||||
# or "[topic] id=terrain_some_id" identifying its description in [help]
|
# 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 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 ##
|
# ## Water ##
|
||||||
@ -427,7 +429,7 @@ Most units receive 20 to 40% defense in sand."
|
|||||||
[/terrain_type]
|
[/terrain_type]
|
||||||
|
|
||||||
[terrain_type]
|
[terrain_type]
|
||||||
symbol_image="misc/brazier-embellishment"
|
symbol_image=misc/brazier-embellishment
|
||||||
id=brazier
|
id=brazier
|
||||||
editor_name= _ "Brazier"
|
editor_name= _ "Brazier"
|
||||||
string=^Eb
|
string=^Eb
|
||||||
@ -436,7 +438,7 @@ Most units receive 20 to 40% defense in sand."
|
|||||||
[/terrain_type]
|
[/terrain_type]
|
||||||
|
|
||||||
[terrain_type]
|
[terrain_type]
|
||||||
symbol_image="misc/brazier-A01"
|
symbol_image=misc/brazier-A01
|
||||||
id=brazier-lit
|
id=brazier-lit
|
||||||
editor_name= _ "Lit Brazier"
|
editor_name= _ "Lit Brazier"
|
||||||
string=^Ebn
|
string=^Ebn
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
#-*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
|
|
||||||
"""
|
"""
|
||||||
A script to create the "Terrain Table" on the TerrainCodeTableWML wiki page.
|
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.)
|
# directly. (They're only there to make aliasing work.)
|
||||||
if i[0].startswith(" "):
|
if i[0].startswith(" "):
|
||||||
continue
|
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
|
# Create a dictionary of key and values
|
||||||
content = dict([v.strip().split("=") for v in i])
|
content = dict([v.strip().split("=") for v in i])
|
||||||
# Hidden things shouldn't be displayed
|
# Hidden things shouldn't be displayed
|
||||||
@ -90,13 +96,12 @@ dest='output_path', help="The location of the output file.")
|
|||||||
path = args.path
|
path = args.path
|
||||||
output_path = args.output_path
|
output_path = args.output_path
|
||||||
|
|
||||||
if not os.path.exists(path) and not path.endswith('.cfg'):
|
if not os.path.exists(path) or not path.endswith('.cfg'):
|
||||||
print("Invalid path: '%s' does not exist") % path
|
print("Invalid path: '%s' does not exist or not a .cfg file.") % path
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
with open(path, "r") as input_file:
|
with open(path, "r") as input_file:
|
||||||
data = input_file.read()
|
data = input_file.read()
|
||||||
|
|
||||||
data = parse_terrain(data)
|
data = parse_terrain(data)
|
||||||
|
|
||||||
with open(output_path, "w") as output:
|
with open(output_path, "w") as output:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user