[wmlunits] Started working on a per-addon log...
...listing all the unit WML mistakes in the addon's unit definitions.
This commit is contained in:
parent
5c6234c6b0
commit
a09daf74ea
2 changed files with 34 additions and 18 deletions
|
@ -37,7 +37,7 @@ error_only_once = {}
|
|||
def error_message(message):
|
||||
if message in error_only_once: return
|
||||
error_only_once[message] = 1
|
||||
sys.stderr.write(message)
|
||||
write_error(message)
|
||||
|
||||
helpers.error_message = error_message
|
||||
|
||||
|
@ -99,7 +99,7 @@ class GroupByRace:
|
|||
|
||||
def unitfilter(self, unit):
|
||||
if not self.campaign: return True
|
||||
return self.campaign == unit.campaigns[0]
|
||||
return self.campaign in unit.campaigns
|
||||
|
||||
def groups(self, unit):
|
||||
return [unit.race]
|
||||
|
@ -578,7 +578,7 @@ class HTMLOutput:
|
|||
crown = u" ♚"
|
||||
|
||||
uaddon = "mainline"
|
||||
if u.campaigns[0] != "mainline": uaddon = self.addon
|
||||
if "mainline" not in u.campaigns: uaddon = self.addon
|
||||
link = "../../%s/%s/%s.html" % (uaddon, self.isocode, uid)
|
||||
write("<div class=\"i\"><a href=\"%s\" title=\"id=%s\">%s</a>" % (
|
||||
link, uid, u"i"))
|
||||
|
@ -749,7 +749,7 @@ class HTMLOutput:
|
|||
write("</td><td>\n")
|
||||
for pid in self.forest.get_parents(uid):
|
||||
punit = self.wesnoth.unit_lookup[pid]
|
||||
if unit.campaigns[0] == "mainline" and punit.campaigns[0] != "mainline":
|
||||
if "mainline" in unit.campaigns and "mainline" not in punit.campaigns:
|
||||
continue
|
||||
|
||||
if "mainline" in unit.campaigns: addon = "mainline"
|
||||
|
@ -768,14 +768,14 @@ class HTMLOutput:
|
|||
if "mainline" in cunit.campaigns: addon = "mainline"
|
||||
else: addon = self.addon
|
||||
link = "../../%s/%s/%s.html" % (addon, self.isocode, cid)
|
||||
if unit.campaigns[0] == "mainline" and cunit.campaigns[0] != "mainline":
|
||||
if "mainline" in unit.campaigns and "mainline" not in cunit.campaigns:
|
||||
continue
|
||||
name = self.wesnoth.get_unit_value(cunit, "name",
|
||||
translation=self.translation.translate)
|
||||
except KeyError:
|
||||
error_message("Warning: Unit %s not found.\n" % cid)
|
||||
name = cid
|
||||
if unit.campaigns[0] == "mainline": continue
|
||||
if "mainline" in unit.campaigns: continue
|
||||
link = self.target
|
||||
write("\n<a href=\"%s\">%s</a>" % (link, name))
|
||||
write("</td>\n")
|
||||
|
@ -1037,7 +1037,7 @@ def generate_single_unit_reports(addon, isocode, wesnoth):
|
|||
html.analyze_units(grouper)
|
||||
|
||||
for uid, unit in wesnoth.unit_lookup.items():
|
||||
if unit.campaigns[0] == "mainline" and addon != "mainline": continue
|
||||
if "mainline" in unit.campaigns and addon != "mainline": continue
|
||||
filename = os.path.join(path, "%s.html" % uid)
|
||||
|
||||
# We probably can come up with something better.
|
||||
|
|
|
@ -103,11 +103,7 @@ def list_contents():
|
|||
def list_campaigns(addon):
|
||||
campaigns = local.wesnoth.parser.get_all(tag = "campaign")
|
||||
info = []
|
||||
|
||||
if addon == "mainline":
|
||||
# Fake mainline campaign to have an overview of the mainline units
|
||||
append(info, "mainline", "", name = "Units", domain = "wesnoth-help")
|
||||
|
||||
|
||||
for campaign in campaigns:
|
||||
cid = campaign.get_text_val("id")
|
||||
append(info, cid, campaign.get_text_val("define"), c = campaign)
|
||||
|
@ -131,11 +127,9 @@ def list_contents():
|
|||
return info.get_text_val("version") + "*" + info.get_text_val("uploads")
|
||||
except wmlparser2.WMLError as e:
|
||||
print(e)
|
||||
|
||||
|
||||
try: os.makedirs(options.output + "/mainline")
|
||||
except OSError: pass
|
||||
|
||||
print("mainline")
|
||||
|
||||
try:
|
||||
batchlist = yaml.load(open(options.list))
|
||||
|
@ -149,15 +143,23 @@ def list_contents():
|
|||
batchlist[-1]["name"] = name
|
||||
return batchlist[-1]
|
||||
|
||||
print("mainline")
|
||||
|
||||
info = search("mainline")
|
||||
info["version"] = "mainline"
|
||||
info["parsed"] = "false"
|
||||
|
||||
|
||||
parse("{core}{multiplayer/eras.cfg}", "SKIP_CORE")
|
||||
info["eras"] = list_eras("mainline")
|
||||
|
||||
parse("{core}{campaigns}", "SKIP_CORE")
|
||||
info["campaigns"] = list_campaigns("mainline")
|
||||
# Fake mainline campaign to have an overview of the mainline units
|
||||
info["campaigns"] = []
|
||||
append(info["campaigns"], "mainline", "", name = "Units", domain = "wesnoth-help")
|
||||
|
||||
if not options.addons_only:
|
||||
|
||||
parse("{core}{campaigns}", "SKIP_CORE")
|
||||
info["campaigns"] += list_campaigns("mainline")
|
||||
|
||||
addons = []
|
||||
if options.addons:
|
||||
|
@ -198,6 +200,8 @@ def list_contents():
|
|||
|
||||
def process_campaign_or_era(addon, cid, define, batchlist):
|
||||
n = 0
|
||||
|
||||
print(addon + ": " + cid)
|
||||
|
||||
wesnoth = helpers.WesnothList(
|
||||
options.wesnoth,
|
||||
|
@ -275,6 +279,14 @@ def batch_process():
|
|||
try: os.makedirs(d)
|
||||
except OSError: pass
|
||||
logname = d + "/error.log"
|
||||
|
||||
def err(mess):
|
||||
ef = open(logname, "a")
|
||||
ef.write(str(mess))
|
||||
ef.close()
|
||||
|
||||
html_output.write_error = err
|
||||
|
||||
try:
|
||||
if not worked:
|
||||
print(name + " not found")
|
||||
|
@ -287,6 +299,8 @@ def batch_process():
|
|||
|
||||
for campaign in addon.get("campaigns", []):
|
||||
cid = campaign["id"]
|
||||
if cid == None: cid = campaign["define"]
|
||||
if cid == None: cid = name
|
||||
n = process_campaign_or_era(name, cid, campaign["define"], batchlist)
|
||||
campaign["units"] = n
|
||||
|
||||
|
@ -376,6 +390,8 @@ if __name__ == '__main__':
|
|||
help = "List available eras and campaigns.")
|
||||
op.add_option("-B", "--batch",
|
||||
help = "Batch process the given list.")
|
||||
op.add_option("-A", "--addons-only", action = "store_true",
|
||||
help = "Do only process addons (for debugging).")
|
||||
op.add_option("-v", "--verbose", action = "store_true")
|
||||
options, args = op.parse_args()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue