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