__init__.py 484 B

1234567891011121314151617181920
  1. import os
  2. def is_root(path):
  3. return os.path.exists(os.path.join(path, ".arcadia.root")) or os.path.exists(os.path.join(path, 'devtools', 'ya', 'ya.conf.json'))
  4. def detect_root(path, detector=is_root):
  5. return _find_path(path, detector)
  6. def _find_path(starts_from, check):
  7. p = os.path.realpath(starts_from)
  8. while True:
  9. if check(p):
  10. return p
  11. next_p = os.path.dirname(p)
  12. if next_p == p:
  13. return None
  14. p = next_p