/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
library/python/find_root/__init__.py
20 строк
484 B
qkrorlqr
Initial NBS OpenSource export
28 апр 2023, 21:54
28 апр 2023, 21:54
783a858
Код
Авторство
О чём код?
import os def is_root(path): return os.path.exists(os.path.join(path, ".arcadia.root")) or os.path.exists(os.path.join(path, 'devtools', 'ya', 'ya.conf.json')) def detect_root(path, detector=is_root): return _find_path(path, detector) def _find_path(starts_from, check): p = os.path.realpath(starts_from) while True: if check(p): return p next_p = os.path.dirname(p) if next_p == p: return None p = next_p