New logic in wmllint for checking tags that should have translation marks...

(such as [message]) and tags that should not (such as
[speaker]). Also, fixes for all but one of the glitches found with
this code.
This commit is contained in:
Eric S. Raymond 2008-02-02 10:35:44 +00:00
parent 64d9943f7b
commit 793b94b23b
13 changed files with 57 additions and 35 deletions

View file

@ -136,7 +136,7 @@
[unit]
description={DESCRIPTION}
user_description={UDESCRIPTION}
user_description={UDESCRIPTION} # wmllint: ignore
type={TYPE}
side={SIDE}
x,y=$possible_guard_locations[$random_location_index].x,$possible_guard_locations[$random_location_index].y

View file

@ -245,8 +245,8 @@
side=1
type=Dwarvish Ulfserker
x,y=14,22
user_description=Ulfdain
description= _ "Ulfdain"
user_description=_ Ulfdain
description= "Ulfdain"
unrenamable=yes
random_traits=yes
upkeep=1

View file

@ -129,7 +129,7 @@
[unit]
type={TYPE}
description={DESCRIPTION}
user_description={USER_DESCRIPTION}
user_description={USER_DESCRIPTION} # wmllint: ignore
x,y={X},{Y}
side=1
random_traits=yes
@ -141,7 +141,7 @@
side=2
type={TYPE}
x,y={X},{Y}
user_description={USER_DESCRIPTION}
user_description={USER_DESCRIPTION} # wmllint: ignore
random_traits=yes
facing=sw
[/unit]

View file

@ -90,7 +90,8 @@
[side]
race=Human
type=Transport Galleon
description= _ "Transport Galleon"
description=Transport Galleon
user_description=_ Transport Galleon
side=3
no_leader=yes
team_name=Humans
@ -203,7 +204,8 @@
[unit]
side=3
id=Transport
description= _ "Transport Galleon"
description="Transport Galleon"
user_description= _ "Transport Galleon"
type=Transport Galleon
name= _ "Transport"
ai_special=guardian
@ -213,7 +215,8 @@
[unit]
side=2
id=Transport
description= _ "Landing Galleon"
description="Landing Galleon"
user_description= _ "Landing Galleon"
type=Transport Galleon
ai_special=guardian
x=7

View file

@ -65,7 +65,7 @@
side=2
x,y={X},{Y}
description={NAME}
user_description=Masked Dwarf
user_description=_ "Masked Dwarf"
[/unit]
#enddef
{MASKED_ULFSERKER 38 12 Ulfserker1}
@ -81,7 +81,7 @@
side=2
x,y=40,13
description=Steelclad1
user_description=Masked Dwarf
user_description=_ "Masked Dwarf"
[/unit]
#endif

View file

@ -228,8 +228,8 @@
[/filter]
[message]
speaker="Aiglondur"
message="Rally on me, everyone. We have better things to do than brawl with elves."
description="Aiglondur"
message=_"Rally on me, everyone. We have better things to do than brawl with elves."
[/message]
[if]

View file

@ -233,8 +233,8 @@
[/filter]
[message]
speaker=Aiglondur
message="Kal Kartha is taken. Our mission has failed."
description=Aiglondur
message=_ "Kal Kartha is taken. Our mission has failed."
[/message]
[endlevel]
@ -252,7 +252,7 @@
[message]
speaker=Angarthing
message="A runemaster? There had been none such since Thursagan's day. And for one to lead a holding was unheard-of; they tended towards the solitary life."
message=_"A runemaster? There had been none such since Thursagan's day. And for one to lead a holding was unheard-of; they tended towards the solitary life."
[/message]
[message]

View file

@ -311,17 +311,17 @@
[message]
speaker=Angarthing
message="Wait...the lich's apparent death was another illusion. In truth he ran through that doorway behind the throne."
message=_"Wait...the lich's apparent death was another illusion. In truth he ran through that doorway behind the throne."
[/message]
[message]
speaker=Dulcatulos
message="Then Karrag has fled to the underlevels. None but his masked ones go there any more."
message=_"Then Karrag has fled to the underlevels. None but his masked ones go there any more."
[/message]
[message]
speaker=Angarthing
message="We must follow. Quickly! It may be his talk of perverting the Hammer was merely mad raving, but we cannot allow the risk that his foul spell might succeed."
message=_"We must follow. Quickly! It may be his talk of perverting the Hammer was merely mad raving, but we cannot allow the risk that his foul spell might succeed."
[/message]
[endlevel]
@ -337,7 +337,7 @@
[message]
speaker=Aiglondur
message="Without Dulcatulos to explain our actions to the Kal Karthans we'll have to fight them, too. Our mission has failed."
message=_"Without Dulcatulos to explain our actions to the Kal Karthans we'll have to fight them, too. Our mission has failed."
[/message]
[endlevel]

View file

@ -1002,7 +1002,7 @@
[message]
speaker=Aiglondur
message="Without Dulcatulos to explain our actions to the Kal Karthans we'll have to fight them, too. Our mission has failed."
message=_"Without Dulcatulos to explain our actions to the Kal Karthans we'll have to fight them, too. Our mission has failed."
[/message]
[endlevel]

View file

@ -80,7 +80,7 @@
[unit]
type={TYPE}
description={NAME}
user_description={NAME}
user_description={NAME} # wmllint: ignore
side=3
x,y={X},{Y}
[/unit]
@ -135,7 +135,7 @@
[unit]
type=Lancer
description=Pelias
user_description="Pelias"
user_description=_"Pelias"
side=2
x,y=12,11
[/unit]

View file

@ -107,7 +107,7 @@
#endif
side=1
description={NAME}
user_description={USERNAME}
user_description={USERNAME} # wmllint: ignore
x={X}
y={Y}
[modifications]

View file

@ -221,7 +221,7 @@
type=Eyestalk
x,y=10,8
description=Eye Guardian
user_description=""
user_description=_ "Eye Guardian"
facing=sw
[/unit]

View file

@ -702,15 +702,20 @@ def sanity_check(filename, lines):
present = []
in_scenario = False
in_person = False
in_objective = False
ignoreable = False
for i in range(len(lines)):
if "[scenario]" in lines[i]:
in_scenario = True
elif "[/scenario]" in lines[i]:
in_scenario = False
elif "[objective]" in lines[i] or "[kill]" in lines[i] or "[object]" in lines[i] or "[move_unit_fake]" in lines[i] or "[scroll_to_unit]" in lines[i]:
elif "[objective]" in lines[i]:
in_objective = True
elif "[/objective]" in lines[i]:
in_objective = False
elif "[kill]" in lines[i] or "[object]" in lines[i] or "[move_unit_fake]" in lines[i] or "[scroll_to_unit]" in lines[i]:
ignoreable = True
elif "[/objective]" in lines[i] or "[/kill]" in lines[i] or "[/object]" in lines[i] or "[/move_unit_fake]" in lines[i] or "[/scroll_to_unit]" in lines[i]:
elif "[/kill]" in lines[i] or "[/object]" in lines[i] or "[/move_unit_fake]" in lines[i] or "[/scroll_to_unit]" in lines[i]:
ignoreable = False
elif "[side]" in lines[i] or "[unit]" in lines[i] or "[recall]" in lines[i]:
in_person = True
@ -726,17 +731,31 @@ def sanity_check(filename, lines):
continue
try:
(key, prefix, value, comment) = parse_attribute(lines[i])
if "wmllint: ignore" in comment:
continue
has_tr_mark = value.lstrip().startswith("_")
if key == 'role':
present.append(value)
if "wmllint: ignore" in comment or key != "description":
continue
if in_person:
present.append(value)
elif value in ('narrator', 'unit', 'second_unit') or value[0] in ("$", "{"):
continue
elif value not in present:
print '"%s", line %d: unknown \'%s\' referred to by description' \
% (filename, i+1, value)
if key == "speaker" and has_tr_mark:
print '"%s", line %d: %s should not have translation mark' \
% (filename, i+1, key)
elif key in ("message", "user_description") and not value.startswith("$") and not has_tr_mark:
print '"%s", line %d: %s needs translation mark' \
% (filename, i+1, key)
elif key == "description":
if in_objective and not has_tr_mark:
print '"%s", line %d: description in [objectives] needs translation mark' \
% (filename, i+1)
elif not in_objective and has_tr_mark:
print '"%s", line %d: description should not have translation mark' \
% (filename, i+1)
if in_person:
present.append(value)
elif value in ('narrator', 'unit', 'second_unit') or value[0] in ("$", "{"):
continue
elif not in_objective and value not in present:
print '"%s", line %d: unknown \'%s\' referred to by description' \
% (filename, i+1, value)
except TypeError:
pass
# Interpret magic comments for setting the sage pattern of units.