mirror of https://github.com/ArduPilot/ardupilot
Tools: throw an error on duplication parameters in libraries
This commit is contained in:
parent
090ef6f2e4
commit
2d127c27c3
|
@ -16,17 +16,24 @@ class Vehicle(object):
|
|||
|
||||
|
||||
class Library(object):
|
||||
def __init__(self, name, reference=None, not_rst=False):
|
||||
def __init__(self, name, reference=None, not_rst=False, check_duplicates=False):
|
||||
self.set_name(name)
|
||||
self.params = []
|
||||
if reference is not None:
|
||||
self.reference = reference
|
||||
self.not_rst = not_rst
|
||||
self.check_duplicates = check_duplicates
|
||||
|
||||
def set_name(self, name):
|
||||
self.name = name
|
||||
self.reference = name
|
||||
|
||||
def has_param(self, pname):
|
||||
for p in self.params:
|
||||
if pname == p.name:
|
||||
return True
|
||||
return False
|
||||
|
||||
known_param_fields = [
|
||||
'Description',
|
||||
'DisplayName',
|
||||
|
|
|
@ -90,7 +90,7 @@ def debug(str_to_print):
|
|||
|
||||
def lua_applets():
|
||||
'''return list of Library objects for lua applets and drivers'''
|
||||
lua_lib = Library("", reference="Lua Script", not_rst=True)
|
||||
lua_lib = Library("", reference="Lua Script", not_rst=True, check_duplicates=True)
|
||||
patterns = ["libraries/AP_Scripting/applets/*.lua", "libraries/AP_Scripting/drivers/*.lua"]
|
||||
paths = []
|
||||
for p in patterns:
|
||||
|
@ -335,6 +335,9 @@ def process_library(vehicle, library, pathprefix=None):
|
|||
continue
|
||||
|
||||
p.path = path # Add path. Later deleted - only used for duplicates
|
||||
if library.check_duplicates and library.has_param(p.name):
|
||||
error("Duplicate parameter %s in %s" % (p.name, library.name))
|
||||
continue
|
||||
library.params.append(p)
|
||||
|
||||
group_matches = prog_groups.findall(p_text)
|
||||
|
|
Loading…
Reference in New Issue