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