From feda165fc1ffebac672b7f060c3f42bd2b1b578e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 12 Sep 2008 06:49:24 +0000 Subject: [PATCH] Teach wmllint to report invalid unit names in advances_to attributes. --- data/tools/wmllint | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/data/tools/wmllint b/data/tools/wmllint index 4c56617a2be..1b6e437e41c 100755 --- a/data/tools/wmllint +++ b/data/tools/wmllint @@ -236,6 +236,7 @@ unit_types = [] derived_units = [] usage = {} sides = [] +advances = [] movetypes = [] unit_movetypes = [] races = [] @@ -346,6 +347,11 @@ def sanity_check(filename, lines): assert(unit_id) unit_race = value unit_races.append((unit_id, filename, i+1, unit_race)) + elif key == "advances_to": + assert(unit_id) + advancements = value + if advancements.strip() != "null": + advances.append((unit_id, filename, i+1, advancements)) except TypeError: pass if "{SPECIAL_NOTES}" in lines[i]: @@ -620,6 +626,13 @@ def consistency_check(): if base_unit not in unit_types: print '"%s", line %d: derivation of %s from %s does not resolve' \ % (filename, line, unit_type, base_unit) + # Check that all advancements are known units + for (unit_id, filename, lineno, advancements) in advances: + advancements = map(string.strip, advancements.split(",")) + bad_advancements = filter(lambda x: x not in (unit_types+derivedlist), advancements) + if bad_advancements: + print '"%s", line %d: %s has unknown advancements %s' \ + % (filename, lineno, unit_id, bad_advancements) # Syntax transformations