MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / get_project_root

Function get_project_root

src/core/utils.py:383–399  ·  view source on GitHub ↗

获取项目根目录 Returns: 项目根目录 Path 对象

()

Source from the content-addressed store, hash-verified

381
382
383def get_project_root() -> Path:
384 """
385 获取项目根目录
386
387 Returns:
388 项目根目录 Path 对象
389 """
390 # 当前文件所在目录
391 current_dir = Path(__file__).parent
392
393 # 向上查找直到找到项目根目录(包含 pyproject.toml 或 setup.py)
394 for parent in [current_dir] + list(current_dir.parents):
395 if (parent / "pyproject.toml").exists() or (parent / "setup.py").exists():
396 return parent
397
398 # 如果找不到,返回当前目录的父目录
399 return current_dir.parent
400
401
402def get_data_dir() -> Path:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected