38def find_oksincludes(includes:list[str], extra_dirs:list[str] = []):
39 includefiles = []
40
41 searchdirs = [path for path in os.environ["DUNEDAQ_DB_PATH"].split(":")]
42 for dir in extra_dirs:
43 searchdirs.append(dir)
44
45 for inc in includes:
46
47 match = False
48 inc = inc.removesuffix(".xml")
49 if inc.endswith(".data"):
50 sub_dirs = ["config", "data"]
51 elif inc.endswith(".schema"):
52 sub_dirs = ["schema"]
53 else:
54 sub_dirs = ["*"]
55 inc = inc + "*"
56 for path in searchdirs:
57
58 matches = glob.glob(f"{inc}.xml", root_dir=path)
59 if len(matches) == 0:
60 for search_dir in sub_dirs:
61
62 matches = glob.glob(f"{search_dir}/{inc}.xml", root_dir=path)
63 for filename in matches:
64 if filename not in includefiles:
65 print(f"Adding {filename} to include list")
66 includefiles.append(filename)
67
68
69 match = True
70 break
71 if match:
72 break
73 if match:
74 break
75 else:
76 for filename in matches:
77 if filename not in includefiles:
78 print(f"Adding {filename} to include list")
79 includefiles.append(filename)
80
81
82 match = True
83 break
84
85 if not match:
86 print(f"Error could not find include file for {inc}")
87 return [False, []]
88
89 return [True, includefiles]
90
91
92