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
|
||||
[schema]
|
||||
identifier="re ^[a-zA-Z0-9_ ]+$"
|
||||
identifierlist="re ^([a-zA-Z0-9_ ]+,)*[a-zA-Z0-9_ ]+$"
|
||||
string="re ^[\d\w\s]*$"
|
||||
string="re ^[ -~]+$"
|
||||
integer="re ^(\+|-)?[0-9]+$"
|
||||
float="re ^(\+|-)?[0-9]+(\.[0-9]*)?$"
|
||||
boolean="enum true,false,yes,no,on,off"
|
||||
|
@ -16,7 +15,6 @@
|
|||
# All possible root elements
|
||||
_about="repeated about"
|
||||
_advanced_preference="repeated advanced_preference"
|
||||
_ais="required ais"
|
||||
_binary_path="repeated binary_path"
|
||||
_campaign="repeated campaign"
|
||||
_fonts="optional fonts"
|
||||
|
@ -29,6 +27,8 @@
|
|||
_textdomain="repeated textdomain"
|
||||
_theme="repeated theme"
|
||||
_units="optional units"
|
||||
_section="optional section"
|
||||
_topic="repeated topic" # TODO: De algum jeito, tem que dizer que depende do 'section'
|
||||
[/root]
|
||||
|
||||
[about]
|
||||
|
@ -87,9 +87,9 @@
|
|||
abbrev="required identifier translatable"
|
||||
define="required identifier" #TODO: maybe require it to be uppercase?
|
||||
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
|
||||
extra_defines="optional string" #TODO: should be a list of identifiers, maybe uppercase?
|
||||
extra_defines="optional string list"
|
||||
first_scenario="required identifier"
|
||||
icon="optional path"
|
||||
id="required string"
|
||||
|
@ -111,14 +111,15 @@
|
|||
id="forbidden identifier"
|
||||
inherit="optional boolean"
|
||||
[/female:unit_type]
|
||||
interval="re ^(\d+|\d+-\d+)$"
|
||||
[font]
|
||||
codepoints="required string" #TODO: should be a list of integers
|
||||
codepoints="required interval list"
|
||||
name="required path"
|
||||
[/font]
|
||||
[fonts]
|
||||
_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]
|
||||
# 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]+$"
|
||||
|
@ -262,7 +263,7 @@
|
|||
sort_sections="optional boolean"
|
||||
sort_topics="optional sort_topics_type"
|
||||
title="required string translatable"
|
||||
topics="optional string" # TODO: list of identifiers
|
||||
topics="optional string list"
|
||||
[/section]
|
||||
#[terrain_graphics]
|
||||
# #subtags here
|
||||
|
|
|
@ -59,12 +59,20 @@ class Validator:
|
|||
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)
|
||||
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:
|
||||
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:
|
||||
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
|
||||
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)
|
||||
|
|
Loading…
Add table
Reference in a new issue