Created the optional parameter "list"
Other minor improvements and updates in wmlvalidator
This commit is contained in:
parent
aeb2dc65c1
commit
2eeac0248c
2 changed files with 20 additions and 11 deletions
|
@ -1,8 +1,7 @@
|
||||||
#textdomain wesnoth
|
#textdomain wesnoth
|
||||||
[schema]
|
[schema]
|
||||||
identifier="re ^[a-zA-Z0-9_ ]+$"
|
identifier="re ^[a-zA-Z0-9_ ]+$"
|
||||||
identifierlist="re ^([a-zA-Z0-9_ ]+,)*[a-zA-Z0-9_ ]+$"
|
string="re ^[ -~]+$"
|
||||||
string="re ^[\d\w\s]*$"
|
|
||||||
integer="re ^(\+|-)?[0-9]+$"
|
integer="re ^(\+|-)?[0-9]+$"
|
||||||
float="re ^(\+|-)?[0-9]+(\.[0-9]*)?$"
|
float="re ^(\+|-)?[0-9]+(\.[0-9]*)?$"
|
||||||
boolean="enum true,false,yes,no,on,off"
|
boolean="enum true,false,yes,no,on,off"
|
||||||
|
@ -16,7 +15,6 @@
|
||||||
# All possible root elements
|
# All possible root elements
|
||||||
_about="repeated about"
|
_about="repeated about"
|
||||||
_advanced_preference="repeated advanced_preference"
|
_advanced_preference="repeated advanced_preference"
|
||||||
_ais="required ais"
|
|
||||||
_binary_path="repeated binary_path"
|
_binary_path="repeated binary_path"
|
||||||
_campaign="repeated campaign"
|
_campaign="repeated campaign"
|
||||||
_fonts="optional fonts"
|
_fonts="optional fonts"
|
||||||
|
@ -29,6 +27,8 @@
|
||||||
_textdomain="repeated textdomain"
|
_textdomain="repeated textdomain"
|
||||||
_theme="repeated theme"
|
_theme="repeated theme"
|
||||||
_units="optional units"
|
_units="optional units"
|
||||||
|
_section="optional section"
|
||||||
|
_topic="repeated topic" # TODO: De algum jeito, tem que dizer que depende do 'section'
|
||||||
[/root]
|
[/root]
|
||||||
|
|
||||||
[about]
|
[about]
|
||||||
|
@ -87,9 +87,9 @@
|
||||||
abbrev="required identifier translatable"
|
abbrev="required identifier translatable"
|
||||||
define="required identifier" #TODO: maybe require it to be uppercase?
|
define="required identifier" #TODO: maybe require it to be uppercase?
|
||||||
description="required string translatable"
|
description="required string translatable"
|
||||||
difficulties="required string" #TODO: should be a list of identifiers, same maybe as above
|
difficulties="required string list"
|
||||||
difficulty_descriptions="required string" #TODO: this one's especially complicated
|
difficulty_descriptions="required string" #TODO: this one's especially complicated
|
||||||
extra_defines="optional string" #TODO: should be a list of identifiers, maybe uppercase?
|
extra_defines="optional string list"
|
||||||
first_scenario="required identifier"
|
first_scenario="required identifier"
|
||||||
icon="optional path"
|
icon="optional path"
|
||||||
id="required string"
|
id="required string"
|
||||||
|
@ -111,14 +111,15 @@
|
||||||
id="forbidden identifier"
|
id="forbidden identifier"
|
||||||
inherit="optional boolean"
|
inherit="optional boolean"
|
||||||
[/female:unit_type]
|
[/female:unit_type]
|
||||||
|
interval="re ^(\d+|\d+-\d+)$"
|
||||||
[font]
|
[font]
|
||||||
codepoints="required string" #TODO: should be a list of integers
|
codepoints="required interval list"
|
||||||
name="required path"
|
name="required path"
|
||||||
[/font]
|
[/font]
|
||||||
[fonts]
|
[fonts]
|
||||||
_font="repeated font"
|
_font="repeated font"
|
||||||
|
|
||||||
order="required string" #TODO: should be a list of paths
|
order="required string list" #TODO: should be a list of paths
|
||||||
[/fonts]
|
[/fonts]
|
||||||
# this is a list of path:integer
|
# this is a list of path:integer
|
||||||
flag_image_type="re ^((([a-zA-Z0-9_\-.+]+/)*[a-zA-Z0-9_\-.+]+):[0-9]+,)*(([a-zA-Z0-9_\-.+]+/)*[a-zA-Z0-9_\-.+]+):[0-9]+$"
|
flag_image_type="re ^((([a-zA-Z0-9_\-.+]+/)*[a-zA-Z0-9_\-.+]+):[0-9]+,)*(([a-zA-Z0-9_\-.+]+/)*[a-zA-Z0-9_\-.+]+):[0-9]+$"
|
||||||
|
@ -262,7 +263,7 @@
|
||||||
sort_sections="optional boolean"
|
sort_sections="optional boolean"
|
||||||
sort_topics="optional sort_topics_type"
|
sort_topics="optional sort_topics_type"
|
||||||
title="required string translatable"
|
title="required string translatable"
|
||||||
topics="optional string" # TODO: list of identifiers
|
topics="optional string list"
|
||||||
[/section]
|
[/section]
|
||||||
#[terrain_graphics]
|
#[terrain_graphics]
|
||||||
# #subtags here
|
# #subtags here
|
||||||
|
@ -321,7 +322,7 @@
|
||||||
_variation="repeated variation"
|
_variation="repeated variation"
|
||||||
|
|
||||||
#TODO: make [base_unit] do its job
|
#TODO: make [base_unit] do its job
|
||||||
advances_to="optional identifierlist" #should be required
|
advances_to="optional identifier list" #should be required
|
||||||
alignment="optional alignments" # required
|
alignment="optional alignments" # required
|
||||||
cost="optional integer" # required
|
cost="optional integer" # required
|
||||||
description="optional string translatable"
|
description="optional string translatable"
|
||||||
|
|
|
@ -59,12 +59,20 @@ class Validator:
|
||||||
elif attribute.freq == wmlgrammar.FORBIDDEN and nummatches > 0:
|
elif attribute.freq == wmlgrammar.FORBIDDEN and nummatches > 0:
|
||||||
print "(%s:%d) Attribute '[%s] %s' should not appear. It appears %d times" % (node.file, node.line, verbosename, attribute.name, nummatches)
|
print "(%s:%d) Attribute '[%s] %s' should not appear. It appears %d times" % (node.file, node.line, verbosename, attribute.name, nummatches)
|
||||||
for match in matches:
|
for match in matches:
|
||||||
if not attribute.validate(match.data):
|
|
||||||
print "(%s:%d) Attribute '[%s] %s's value should be %s, found: %s" % (node.file, node.line, verbosename, attribute.name, attribute.type, match.data)
|
|
||||||
if 'translatable' in attribute.optionals and match.is_translatable() == False:
|
if 'translatable' in attribute.optionals and match.is_translatable() == False:
|
||||||
print "(%s:%d) Attribute '[%s] %s's value is translatable, but haven't _ at the beginning" % (node.file, node.line, verbosename, attribute.name)
|
print "(%s:%d) Attribute '[%s] %s's value is translatable, but haven't _ at the beginning" % (node.file, node.line, verbosename, attribute.name)
|
||||||
elif 'translatable' not in attribute.optionals and match.is_translatable() == True:
|
elif 'translatable' not in attribute.optionals and match.is_translatable() == True:
|
||||||
print "(%s:%d) Attribute '[%s] %s's value isn't translatable, but have a _ at the beginning" % (node.file, node.line, verbosename, attribute.name)
|
print "(%s:%d) Attribute '[%s] %s's value isn't translatable, but have a _ at the beginning" % (node.file, node.line, verbosename, attribute.name)
|
||||||
|
if 'list' in attribute.optionals:
|
||||||
|
pos = 1
|
||||||
|
for i in match.data.split(","):
|
||||||
|
if i[0] == ' ': i = i[1:]
|
||||||
|
if not attribute.validate(i):
|
||||||
|
print "(%s:%d) Attribute '[%s] %s's value in list should be %s, found at position %d: %s" % (node.file, node.line, verbosename, attribute.name, attribute.type, pos, i)
|
||||||
|
pos += 1
|
||||||
|
else:
|
||||||
|
if not attribute.validate(match.data):
|
||||||
|
print "(%s:%d) Attribute '[%s] %s's value should be %s, found: %s" % (node.file, node.line, verbosename, attribute.name, attribute.type, match.data)
|
||||||
node.remove(match) # Get rid of these so we can see what's left
|
node.remove(match) # Get rid of these so we can see what's left
|
||||||
for attribute in node.get_all_text():
|
for attribute in node.get_all_text():
|
||||||
print "(%s:%d) Attribute '[%s] %s' found, which has no meaning there" % (node.file, node.line, verbosename, attribute.name)
|
print "(%s:%d) Attribute '[%s] %s' found, which has no meaning there" % (node.file, node.line, verbosename, attribute.name)
|
||||||
|
|
Loading…
Add table
Reference in a new issue