mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-10 18:08:30 -04:00
autotest: param_parse.py: correct parsing of Values fields
the regex used to parse the values field later is rather strict - no spaces allowed around the : for example. Canonicalise the string before trying to do anything more with it (including validation)
This commit is contained in:
parent
4ebde78bbf
commit
9e148f245b
@ -307,6 +307,21 @@ def is_number(numberString):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def clean_param(param):
|
||||||
|
if (hasattr(param, "Values")):
|
||||||
|
valueList = param.Values.split(",")
|
||||||
|
new_valueList = []
|
||||||
|
for i in valueList:
|
||||||
|
(start, sep, end) = i.partition(":")
|
||||||
|
if sep != ":":
|
||||||
|
raise ValueError("Expected a colon seperator in (%s)" % (i,))
|
||||||
|
if len(end) == 0:
|
||||||
|
raise ValueError("Expected a colon-separated string, got (%s)" % i)
|
||||||
|
end = end.strip()
|
||||||
|
start = start.strip()
|
||||||
|
new_valueList.append(":".join([start, end]))
|
||||||
|
param.Values = ",".join(new_valueList)
|
||||||
|
|
||||||
def validate(param):
|
def validate(param):
|
||||||
"""
|
"""
|
||||||
Validates the parameter meta data.
|
Validates the parameter meta data.
|
||||||
@ -344,6 +359,9 @@ def validate(param):
|
|||||||
if (param.__dict__["Units"] != "") and (param.__dict__["Units"] not in known_units):
|
if (param.__dict__["Units"] != "") and (param.__dict__["Units"] not in known_units):
|
||||||
error("unknown units field '%s'" % param.__dict__["Units"])
|
error("unknown units field '%s'" % param.__dict__["Units"])
|
||||||
|
|
||||||
|
for vehicle in vehicles:
|
||||||
|
for param in vehicle.params:
|
||||||
|
clean_param(param)
|
||||||
|
|
||||||
for vehicle in vehicles:
|
for vehicle in vehicles:
|
||||||
for param in vehicle.params:
|
for param in vehicle.params:
|
||||||
@ -366,6 +384,10 @@ for library in libraries:
|
|||||||
# not a duplicate, so delete attribute.
|
# not a duplicate, so delete attribute.
|
||||||
delattr(param, "path")
|
delattr(param, "path")
|
||||||
|
|
||||||
|
for library in libraries:
|
||||||
|
for param in library.params:
|
||||||
|
clean_param(param)
|
||||||
|
|
||||||
for library in libraries:
|
for library in libraries:
|
||||||
for param in library.params:
|
for param in library.params:
|
||||||
validate(param)
|
validate(param)
|
||||||
|
Loading…
Reference in New Issue
Block a user