autotest: param_parse.py: recurse, don't glob in lua script dirs

many scripts are now categoriesed e.g. Aerobatics
This commit is contained in:
Peter Barker 2023-04-04 23:52:52 +10:00 committed by Peter Barker
parent ec1d29d806
commit d8bc223fe4

View File

@ -12,7 +12,6 @@ import copy
import os import os
import re import re
import sys import sys
import glob
from argparse import ArgumentParser from argparse import ArgumentParser
from param import (Library, Parameter, Vehicle, known_group_fields, from param import (Library, Parameter, Vehicle, known_group_fields,
@ -91,12 +90,15 @@ def debug(str_to_print):
def lua_applets(): def lua_applets():
'''return list of Library objects for lua applets and drivers''' '''return list of Library objects for lua applets and drivers'''
lua_lib = Library("", reference="Lua Script", not_rst=True, check_duplicates=True) lua_lib = Library("", reference="Lua Script", not_rst=True, check_duplicates=True)
patterns = ["libraries/AP_Scripting/applets/*.lua", "libraries/AP_Scripting/drivers/*.lua"] dirs = ["libraries/AP_Scripting/applets", "libraries/AP_Scripting/drivers"]
paths = [] paths = []
for p in patterns: for d in dirs:
debug("Adding lua paths %s" % p) for root, dirs, files in os.walk(os.path.join(apm_path, d)):
luafiles = glob.glob(os.path.join(apm_path, p)) for file in files:
for f in luafiles: if not file.endswith(".lua"):
continue
f = os.path.join(root, file)
debug("Adding lua path %s" % f)
# the library is expected to have the path as a relative path from within # the library is expected to have the path as a relative path from within
# a vehicle directory # a vehicle directory
f = f.replace(apm_path, "../") f = f.replace(apm_path, "../")