info-tech-canon/src/info_tech_canon/paths.py

16 lines
482 B
Python
Raw Normal View History

"""Corpus location is independent of the installed Python package."""
import os
from pathlib import Path
def infospace_root(root: Path | str | None = None) -> Path:
if root:
return Path(root).resolve()
if os.environ.get("INFO_TECH_CANON_ROOT"):
return Path(os.environ["INFO_TECH_CANON_ROOT"]).resolve()
local = Path.cwd() / "infospace"
if local.is_dir():
return local.resolve()
return Path(__file__).resolve().parents[2] / "infospace"