зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1304176 - Document and refactor query_virtualenv_path; r=ted
We don't need a variable to hold the result. Just use return. The "virtualenv_path" option has a default value, so it should always be set. Add code confirming that. And refactor the code to use less indentation. And remove a branch that can never occur since the virtualenv path is guaranteed to be defined. MozReview-Commit-ID: DZ6LnlxZJFj --HG-- extra : rebase_source : 46682e9d33beb43e0b4fc181b9163afd373e7f70
This commit is contained in:
Родитель
3fd85079b9
Коммит
5fddd4bf5e
|
@ -113,18 +113,21 @@ class VirtualenvMixin(object):
|
|||
optional, two_pass, editable))
|
||||
|
||||
def query_virtualenv_path(self):
|
||||
c = self.config
|
||||
"""Determine the absolute path to the virtualenv."""
|
||||
dirs = self.query_abs_dirs()
|
||||
virtualenv = None
|
||||
|
||||
if 'abs_virtualenv_dir' in dirs:
|
||||
virtualenv = dirs['abs_virtualenv_dir']
|
||||
elif c.get('virtualenv_path'):
|
||||
if os.path.isabs(c['virtualenv_path']):
|
||||
virtualenv = c['virtualenv_path']
|
||||
else:
|
||||
virtualenv = os.path.join(dirs['abs_work_dir'],
|
||||
c['virtualenv_path'])
|
||||
return virtualenv
|
||||
return dirs['abs_virtualenv_dir']
|
||||
|
||||
p = self.config['virtualenv_path']
|
||||
if not p:
|
||||
self.fatal('virtualenv_path config option not set; '
|
||||
'this should never happen')
|
||||
|
||||
if os.path.isabs(p):
|
||||
return p
|
||||
else:
|
||||
return os.path.join(dirs['abs_work_dir'], p)
|
||||
|
||||
def query_python_path(self, binary="python"):
|
||||
"""Return the path of a binary inside the virtualenv, if
|
||||
|
@ -136,10 +139,8 @@ class VirtualenvMixin(object):
|
|||
if self._is_windows():
|
||||
bin_dir = 'Scripts'
|
||||
virtualenv_path = self.query_virtualenv_path()
|
||||
if virtualenv_path:
|
||||
self.python_paths[binary] = os.path.abspath(os.path.join(virtualenv_path, bin_dir, binary))
|
||||
else:
|
||||
self.python_paths[binary] = self.query_exe(binary)
|
||||
self.python_paths[binary] = os.path.abspath(os.path.join(virtualenv_path, bin_dir, binary))
|
||||
|
||||
return self.python_paths[binary]
|
||||
|
||||
def query_python_site_packages_path(self):
|
||||
|
|
Загрузка…
Ссылка в новой задаче