__init__.py 468 B

123456789101112131415
  1. import os
  2. def select_project_config(path, config_paths, arc_root):
  3. # type(str, dict, str) -> Optional[str]
  4. relative_path = os.path.relpath(path, arc_root)
  5. # find longest path
  6. deepest_path = ''
  7. for p in config_paths.keys():
  8. if relative_path.startswith(p) and len(p) > len(deepest_path):
  9. deepest_path = p
  10. config = config_paths[deepest_path]
  11. full_config_path = os.path.join(arc_root, config)
  12. return full_config_path