MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / detect_by_path

Method detect_by_path

mod/project/python/pyenv_tool.py:979–991  ·  view source on GitHub ↗
(self, test_path: Path)

Source from the content-addressed store, hash-verified

977 return res_list
978
979 def detect_by_path(self, test_path: Path):
980 for python_bin_name in os.listdir(test_path):
981 if not self.regexp_name.match(python_bin_name):
982 continue
983 python_bin = Path(test_path) / python_bin_name
984 if python_bin.exists() and python_bin.is_file() and not python_bin.is_symlink() and os.access(python_bin, os.X_OK):
985 fs_inode = os.stat(python_bin).st_ino
986 if fs_inode in self.python_bin_map and len(str(python_bin)) > len(self.python_bin_map[fs_inode]):
987 continue
988 self.python_bin_map[fs_inode] = str(python_bin.resolve())
989 # 如果查询目录不是系统目录,此时应该为Python安装目录, 则只检查一个有效的Python环境
990 if str(test_path) not in _SYS_BIN_PATH:
991 return
992
993 @classmethod
994 def get_py_version(cls, python_bin: str) -> Optional[str]:

Callers 1

detectMethod · 0.95

Calls 5

listdirMethod · 0.80
statMethod · 0.80
matchMethod · 0.45
existsMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected