Returns the closest config relative to filename by doing a depth first search on the prefix tree.
(self, filename: str)
| 37 | temp.config_info = (config_file, config_data) |
| 38 | |
| 39 | def search(self, filename: str) -> tuple[str, dict[str, Any]]: |
| 40 | """ |
| 41 | Returns the closest config relative to filename by doing a depth |
| 42 | first search on the prefix tree. |
| 43 | """ |
| 44 | resolved_file_path_as_tuple = Path(filename).resolve().parts |
| 45 | |
| 46 | temp = self.root |
| 47 | |
| 48 | last_stored_config: tuple[str, dict[str, Any]] = ("", {}) |
| 49 | |
| 50 | for path in resolved_file_path_as_tuple: |
| 51 | if temp.config_info[0]: |
| 52 | last_stored_config = temp.config_info |
| 53 | |
| 54 | if path not in temp.nodes: |
| 55 | break |
| 56 | |
| 57 | temp = temp.nodes[path] |
| 58 | |
| 59 | return last_stored_config |
| 60 | |
| 61 | |
| 62 | @lru_cache(maxsize=1000) |
no outgoing calls