[wmlunits] use translations only for mainline units...
...(very few addon units had translations but creating all the addon units in each language takes a lot of time and .html files). Also report less errors for addons (the addon authors don't get to read them anyway i'm afraid :/)
This commit is contained in:
parent
a5576c461b
commit
7524e6befc
3 changed files with 30 additions and 16 deletions
|
@ -304,7 +304,7 @@ class WesnothList:
|
|||
try: unit.race = self.race_lookup[race]
|
||||
except KeyError:
|
||||
unit.race = None
|
||||
sys.stderr.write("Warning: No race \"%s\" found (%s).\n" % (
|
||||
error_message("Warning: No race \"%s\" found (%s).\n" % (
|
||||
race, unit.get_text_val("id")))
|
||||
movetype = self.get_unit_value(unit, "movement_type")
|
||||
try: unit.movetype = self.movetype_lookup[movetype]
|
||||
|
@ -343,7 +343,7 @@ class WesnothList:
|
|||
try:
|
||||
unit = self.unit_lookup[uid]
|
||||
except KeyError:
|
||||
sys.stderr.write(
|
||||
error_message(
|
||||
("Error: Era '%s' faction '%s' references " +
|
||||
"non-existant unit id '%s'!\n") % (
|
||||
eid,
|
||||
|
@ -361,7 +361,7 @@ class WesnothList:
|
|||
buid = b.get_text_val("id")
|
||||
try: baseunit = self.unit_lookup[buid]
|
||||
except KeyError:
|
||||
sys.stderr.write(
|
||||
error_message(
|
||||
"Warning: No baseunit \"%s\" for \"%s\".\n" % (
|
||||
buid, unit.get_text_val("id")))
|
||||
return None
|
||||
|
@ -420,10 +420,10 @@ class UnitForest:
|
|||
for c in u.children[:]:
|
||||
already2[c.id] = True
|
||||
if c.id in already:
|
||||
sys.stderr.write(
|
||||
"Warning: Unit %s advances to unit %s in a loop.\n" %
|
||||
(u.id, c.id))
|
||||
sys.stderr.write(" Removing advancement %s.\n" % c.id)
|
||||
error_message(
|
||||
("Warning: Unit %s advances to unit %s in a loop.\n" %
|
||||
(u.id, c.id)) +
|
||||
(" Removing advancement %s.\n" % c.id))
|
||||
u.children.remove(c)
|
||||
for c in u.children:
|
||||
recurse(c, already2)
|
||||
|
|
|
@ -20,7 +20,7 @@ def parse_test(wml, d):
|
|||
options.data_dir, no_preprocess = False)
|
||||
try:
|
||||
g.p.parse_text(wml, d)
|
||||
except wmlparser2.WMLError as e:
|
||||
except wmlparser2.WMLError, e:
|
||||
for i, line in enumerate(str(e).splitlines()):
|
||||
print(str(1 + i) + ": " + line)
|
||||
for mo in re.findall("~add-ons/(.*?)[:/]", line):
|
||||
|
@ -104,7 +104,7 @@ def check_runaway():
|
|||
id = un.get_text_val("id")
|
||||
if id: names.append(id)
|
||||
if names: print("Leaked units: " + ", ".join(names))
|
||||
except wmlparser2.WMLError as e:
|
||||
except wmlparser2.WMLError, e:
|
||||
print("Parsing failed!")
|
||||
print("***")
|
||||
print(e)
|
||||
|
|
|
@ -33,6 +33,17 @@ html_footer = '''
|
|||
</body></html>
|
||||
'''.strip()
|
||||
|
||||
error_only_once = {}
|
||||
def error_message(message):
|
||||
if message in error_only_once: return
|
||||
error_only_once[message] = 1
|
||||
sys.stderr.write(message)
|
||||
|
||||
helpers.error_message = error_message
|
||||
|
||||
def reset_errors():
|
||||
error_only_once = {}
|
||||
|
||||
class Translation:
|
||||
def __init__(self, localedir, langcode):
|
||||
self.catalog = {}
|
||||
|
@ -141,7 +152,7 @@ class HTMLOutput:
|
|||
try:
|
||||
au = self.wesnoth.unit_lookup[auid]
|
||||
except KeyError:
|
||||
sys.stderr.write(
|
||||
error_message(
|
||||
"Warning: Unit %s not found as advancement of %s\n" %
|
||||
(auid, repr(uid)))
|
||||
continue
|
||||
|
@ -343,7 +354,7 @@ class HTMLOutput:
|
|||
return self.pic(u, female[0])
|
||||
else:
|
||||
return self.pic(u, u)
|
||||
sys.stderr.write(
|
||||
error_message(
|
||||
"Warning: Missing image for unit %s(%s).\n" % (
|
||||
u.get_text_val("id"), x.name))
|
||||
return None
|
||||
|
@ -626,7 +637,7 @@ class HTMLOutput:
|
|||
name = self.wesnoth.get_unit_value(cunit, "name",
|
||||
translation = self.translation.translate)
|
||||
except KeyError:
|
||||
sys.stderr.write("Warning: Unit %s not found.\n" % cid)
|
||||
error_message("Warning: Unit %s not found.\n" % cid)
|
||||
name = cid
|
||||
if unit.campaign == "mainline": continue
|
||||
write("\n<a href=\"%s\">%s</a>" % (link, name))
|
||||
|
@ -674,7 +685,7 @@ class HTMLOutput:
|
|||
|
||||
picname, error = image_collector.add_image_check(unit.campaign, icon)
|
||||
if error:
|
||||
sys.stderr.write("Error: No attack icon '%s' found for '%s'.\n" % (
|
||||
error_message("Error: No attack icon '%s' found for '%s'.\n" % (
|
||||
icon, uid))
|
||||
icon = os.path.join("../pics", picname)
|
||||
write("<td><img src=\"%s\" alt=\"(image)\"/></td>" % icon)
|
||||
|
@ -700,7 +711,7 @@ class HTMLOutput:
|
|||
if sname:
|
||||
s.append(sname)
|
||||
else:
|
||||
sys.stderr.write(
|
||||
error_message(
|
||||
"Warning: Weapon special %s has no name for %s.\n" % (
|
||||
special.name, uid))
|
||||
s = "<br/>".join(s)
|
||||
|
@ -729,7 +740,7 @@ class HTMLOutput:
|
|||
if r == "-": r = 100
|
||||
try: r = "%d%%" % (100 - int(r))
|
||||
except ValueError:
|
||||
sys.stderr.write("Warning: Invalid resistance %s for %s.\n" % (
|
||||
error_message("Warning: Invalid resistance %s for %s.\n" % (
|
||||
r, uid))
|
||||
rcell = "td"
|
||||
if special: rcell += ' class="special"'
|
||||
|
@ -766,7 +777,7 @@ class HTMLOutput:
|
|||
if d == "-": d = 100
|
||||
try: d = "%d%%" % (100 - int(d))
|
||||
except ValueError:
|
||||
sys.stderr.write("Warning: Invalid defense %s for %s.\n" % (
|
||||
error_message("Warning: Invalid defense %s for %s.\n" % (
|
||||
d, uid))
|
||||
|
||||
write("<tr>\n")
|
||||
|
@ -953,6 +964,7 @@ def generate_report(stuff, isocode):
|
|||
"""
|
||||
|
||||
print "Generating report for %s." % (isocode)
|
||||
reset_errors()
|
||||
|
||||
# Report generation
|
||||
write_index(options.output)
|
||||
|
@ -962,9 +974,11 @@ def generate_report(stuff, isocode):
|
|||
generate_campaign_report(options.output, isocode, "mainline", stuff)
|
||||
|
||||
for campaign in campaigns:
|
||||
if isocode != "C" and not campaign in stuff.is_mainline_campaign: continue
|
||||
generate_campaign_report(options.output, isocode, campaign, stuff)
|
||||
|
||||
for eid in stuff.era_lookup.keys():
|
||||
if isocode != "C" and not eid in stuff.is_mainline_era: continue
|
||||
generate_era_report(options.output, isocode, eid, stuff)
|
||||
|
||||
# Single unit reports.
|
||||
|
|
Loading…
Add table
Reference in a new issue