[[wmlunits fix]]
- Fixed a bug in wmlunits where the era tree omitted units whose parent units belonged to a different faction. - Made wmlunits provide feedback about required parameters.
This commit is contained in:
parent
265a3fbe83
commit
b0e4f12b57
2 changed files with 38 additions and 18 deletions
|
@ -176,7 +176,7 @@ class HTMLOutput:
|
|||
def translate(self, string, domain):
|
||||
return self.translation.translate(string, domain)
|
||||
|
||||
def analyze_units(self, grouper):
|
||||
def analyze_units(self, grouper, add_parents):
|
||||
"""
|
||||
This takes all units belonging to a campaign, then groups them either
|
||||
by race or faction, and creates an advancements tree out of it.
|
||||
|
@ -209,18 +209,19 @@ class HTMLOutput:
|
|||
forest.add_node(helpers.UnitNode(au))
|
||||
new_units_added[auid] = au
|
||||
units_added = new_units_added
|
||||
|
||||
# Also add parent units
|
||||
added = True
|
||||
while added:
|
||||
added = False
|
||||
for uid, u in self.wesnoth.unit_lookup.items():
|
||||
if uid in forest.lookup: continue
|
||||
for auid in u.advance:
|
||||
if auid in forest.lookup:
|
||||
forest.add_node(helpers.UnitNode(u))
|
||||
added = True
|
||||
break
|
||||
|
||||
if add_parents:
|
||||
# Also add parent units
|
||||
added = True
|
||||
while added:
|
||||
added = False
|
||||
for uid, u in self.wesnoth.unit_lookup.items():
|
||||
if uid in forest.lookup: continue
|
||||
for auid in u.advance:
|
||||
if auid in forest.lookup:
|
||||
forest.add_node(helpers.UnitNode(u))
|
||||
added = True
|
||||
break
|
||||
|
||||
forest.update()
|
||||
|
||||
|
@ -678,11 +679,11 @@ class HTMLOutput:
|
|||
write("</tr>\n")
|
||||
write("</table>\n")
|
||||
|
||||
def write_units_tree(self, grouper, title):
|
||||
def write_units_tree(self, grouper, title, add_parents):
|
||||
self.output.write(html_header % {"path": "../../",
|
||||
"title": title})
|
||||
|
||||
n = self.analyze_units(grouper)
|
||||
n = self.analyze_units(grouper, add_parents)
|
||||
self.write_navbar("units_tree")
|
||||
|
||||
self.output.write("<div class=\"main\">")
|
||||
|
@ -1048,7 +1049,7 @@ def generate_campaign_report(addon, isocode, campaign, wesnoth):
|
|||
if not title:
|
||||
title = cid
|
||||
|
||||
n = html.write_units_tree(grouper, title)
|
||||
n = html.write_units_tree(grouper, title, True)
|
||||
|
||||
output.close()
|
||||
|
||||
|
@ -1069,7 +1070,7 @@ def generate_era_report(addon, isocode, era, wesnoth):
|
|||
grouper = GroupByFaction(wesnoth, eid)
|
||||
|
||||
ename = era.get_text_val("name", translation = html.translate)
|
||||
n = html.write_units_tree(grouper, ename)
|
||||
n = html.write_units_tree(grouper, ename, False)
|
||||
|
||||
output.close()
|
||||
|
||||
|
@ -1082,7 +1083,7 @@ def generate_single_unit_reports(addon, isocode, wesnoth):
|
|||
|
||||
html = HTMLOutput(isocode, None, addon, "units", False, wesnoth)
|
||||
grouper = GroupByNothing()
|
||||
html.analyze_units(grouper)
|
||||
html.analyze_units(grouper, True)
|
||||
|
||||
for uid, unit in wesnoth.unit_lookup.items():
|
||||
if unit.hidden: continue
|
||||
|
|
|
@ -47,6 +47,12 @@ def shell(com):
|
|||
|
||||
return p.returncode
|
||||
|
||||
def shell_out(com):
|
||||
p = subprocess.Popen(com,
|
||||
stdout = subprocess.PIPE, stderr = subprocess.PIPE)
|
||||
out, err = p.communicate()
|
||||
return out
|
||||
|
||||
def bash(name):
|
||||
return "'" + name.replace("'", "'\\''") + "'"
|
||||
|
||||
|
@ -429,6 +435,7 @@ if __name__ == '__main__':
|
|||
wiki_output.options = options
|
||||
|
||||
if not options.output and not options.wiki:
|
||||
sys.stderr.write("Need --output (or --wiki).\n")
|
||||
op.print_help()
|
||||
sys.exit(-1)
|
||||
|
||||
|
@ -438,6 +445,14 @@ if __name__ == '__main__':
|
|||
if not options.wesnoth:
|
||||
options.wesnoth = "wesnoth"
|
||||
|
||||
if not options.data_dir:
|
||||
options.data_dir = shell_out([options.wesnoth, "--path"]).strip()
|
||||
print("Using " + options.data_dir + " as data dir.")
|
||||
|
||||
if not options.config_dir:
|
||||
options.config_dir = shell_out([options.wesnoth, "--config-path"]).strip()
|
||||
print("Using " + options.config_dir + " as config dir.")
|
||||
|
||||
if not options.transdir:
|
||||
options.transdir = os.getcwd()
|
||||
|
||||
|
@ -464,6 +479,10 @@ if __name__ == '__main__':
|
|||
languages.sort()
|
||||
else:
|
||||
languages = options.language.split(",")
|
||||
|
||||
if not options.list and not options.batch:
|
||||
sys.stderr.write("Need --list or --batch (or both).\n")
|
||||
sys.exit(-1)
|
||||
|
||||
if options.output:
|
||||
# Generate output dir.
|
||||
|
|
Loading…
Add table
Reference in a new issue