mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-23 08:13:56 -04:00
Tools: autotest: param metadata: allow parsing multi line values
This commit is contained in:
parent
8b36fde0c1
commit
65374a01a3
@ -300,6 +300,7 @@ def process_library(vehicle, library, pathprefix=None):
|
|||||||
# a parameter is considered to be vehicle-specific if
|
# a parameter is considered to be vehicle-specific if
|
||||||
# there does not exist a Values: or Values{VehicleName}
|
# there does not exist a Values: or Values{VehicleName}
|
||||||
# for that vehicle but @Values{OtherVehicle} exists.
|
# for that vehicle but @Values{OtherVehicle} exists.
|
||||||
|
seen_values_or_bitmask_for_this_vehicle = False
|
||||||
seen_values_or_bitmask_for_other_vehicle = False
|
seen_values_or_bitmask_for_other_vehicle = False
|
||||||
for field in fields:
|
for field in fields:
|
||||||
only_for_vehicles = field[1].split(",")
|
only_for_vehicles = field[1].split(",")
|
||||||
@ -313,10 +314,25 @@ def process_library(vehicle, library, pathprefix=None):
|
|||||||
error("tagged param: unknown parameter metadata field '%s'" % field[0])
|
error("tagged param: unknown parameter metadata field '%s'" % field[0])
|
||||||
continue
|
continue
|
||||||
if vehicle.name not in only_for_vehicles:
|
if vehicle.name not in only_for_vehicles:
|
||||||
if len(only_for_vehicles) and field[0] in ['Values', 'Bitmask']:
|
if len(only_for_vehicles) and field[0] in documentation_tags_which_are_comma_separated_nv_pairs:
|
||||||
seen_values_or_bitmask_for_other_vehicle = True
|
seen_values_or_bitmask_for_other_vehicle = True
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
append_value = False
|
||||||
|
if field[0] in documentation_tags_which_are_comma_separated_nv_pairs:
|
||||||
|
if vehicle.name in only_for_vehicles:
|
||||||
|
if seen_values_or_bitmask_for_this_vehicle:
|
||||||
|
append_value = hasattr(p, field[0])
|
||||||
|
seen_values_or_bitmask_for_this_vehicle = True
|
||||||
|
else:
|
||||||
|
if seen_values_or_bitmask_for_this_vehicle:
|
||||||
|
continue
|
||||||
|
append_value = hasattr(p, field[0])
|
||||||
|
|
||||||
value = re.sub('@PREFIX@', library.name, field[2])
|
value = re.sub('@PREFIX@', library.name, field[2])
|
||||||
|
if append_value:
|
||||||
|
setattr(p, field[0], getattr(p, field[0]) + ',' + value)
|
||||||
|
else:
|
||||||
setattr(p, field[0], value)
|
setattr(p, field[0], value)
|
||||||
|
|
||||||
if (getattr(p, 'Values', None) is not None and
|
if (getattr(p, 'Values', None) is not None and
|
||||||
@ -516,7 +532,7 @@ def validate(param, is_library=False):
|
|||||||
i = i.replace(" ", "")
|
i = i.replace(" ", "")
|
||||||
values.append(i.partition(":")[0])
|
values.append(i.partition(":")[0])
|
||||||
if (len(values) != len(set(values))):
|
if (len(values) != len(set(values))):
|
||||||
error("Duplicate values found")
|
error("Duplicate values found" + str({x for x in values if values.count(x) > 1}))
|
||||||
# Validate units
|
# Validate units
|
||||||
if (hasattr(param, "Units")):
|
if (hasattr(param, "Units")):
|
||||||
if (param.__dict__["Units"] != "") and (param.__dict__["Units"] not in known_units):
|
if (param.__dict__["Units"] != "") and (param.__dict__["Units"] not in known_units):
|
||||||
|
Loading…
Reference in New Issue
Block a user