mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-25 17:58:35 +08:00
Make some names public
This commit is contained in:
@@ -31,13 +31,13 @@ class _BaseEnvironment(object):
|
|||||||
|
|
||||||
class Environment(_BaseEnvironment):
|
class Environment(_BaseEnvironment):
|
||||||
def __init__(self, path, executable):
|
def __init__(self, path, executable):
|
||||||
self._base_path = os.path.abspath(path)
|
self.path = os.path.abspath(path)
|
||||||
self._executable = os.path.abspath(executable)
|
self.executable = os.path.abspath(executable)
|
||||||
self.version_info = self._get_version()
|
self.version_info = self._get_version()
|
||||||
|
|
||||||
def _get_version(self):
|
def _get_version(self):
|
||||||
try:
|
try:
|
||||||
process = Popen([self._executable, '--version'], stdout=PIPE, stderr=PIPE)
|
process = Popen([self.executable, '--version'], stdout=PIPE, stderr=PIPE)
|
||||||
stdout, stderr = process.communicate()
|
stdout, stderr = process.communicate()
|
||||||
retcode = process.poll()
|
retcode = process.poll()
|
||||||
if retcode:
|
if retcode:
|
||||||
@@ -56,13 +56,13 @@ class Environment(_BaseEnvironment):
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
version = '.'.join(str(i) for i in self.version_info)
|
version = '.'.join(str(i) for i in self.version_info)
|
||||||
return '<%s: %s in %s>' % (self.__class__.__name__, version, self._base_path)
|
return '<%s: %s in %s>' % (self.__class__.__name__, version, self.path)
|
||||||
|
|
||||||
def get_evaluator_subprocess(self, evaluator):
|
def get_evaluator_subprocess(self, evaluator):
|
||||||
return EvaluatorSubprocess(evaluator, self._get_subprocess())
|
return EvaluatorSubprocess(evaluator, self._get_subprocess())
|
||||||
|
|
||||||
def _get_subprocess(self):
|
def _get_subprocess(self):
|
||||||
return get_subprocess(self._executable)
|
return get_subprocess(self.executable)
|
||||||
|
|
||||||
@memoize_method
|
@memoize_method
|
||||||
def get_sys_path(self):
|
def get_sys_path(self):
|
||||||
@@ -143,7 +143,7 @@ def find_virtualenvs(paths=None, **kwargs):
|
|||||||
virtual_env = _get_virtual_env_from_var()
|
virtual_env = _get_virtual_env_from_var()
|
||||||
if virtual_env is not None:
|
if virtual_env is not None:
|
||||||
yield virtual_env
|
yield virtual_env
|
||||||
_used_paths.add(virtual_env._base_path)
|
_used_paths.add(virtual_env.path)
|
||||||
|
|
||||||
for directory in paths:
|
for directory in paths:
|
||||||
if not os.path.isdir(directory):
|
if not os.path.isdir(directory):
|
||||||
@@ -289,7 +289,7 @@ def _is_safe(executable_path):
|
|||||||
# it's likely an attacker or some Python that was not properly
|
# it's likely an attacker or some Python that was not properly
|
||||||
# installed in the system.
|
# installed in the system.
|
||||||
for environment in find_python_environments():
|
for environment in find_python_environments():
|
||||||
if environment._executable == executable_path:
|
if environment.executable == executable_path:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user