From 5c2e5a3d8dcf05c83a52c3f4fc03b815bd3e86f8 Mon Sep 17 00:00:00 2001 From: David Strobach Date: Sun, 23 Aug 2020 11:16:26 +0200 Subject: [PATCH] vox: Restore vox functionality After the recent changes in environment defaults, the vox xontrib could not "see" the virtual environments and work with them. --- xontrib/voxapi.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xontrib/voxapi.py b/xontrib/voxapi.py index 920e7bef6..154dcffe7 100644 --- a/xontrib/voxapi.py +++ b/xontrib/voxapi.py @@ -332,9 +332,10 @@ class Vox(collections.abc.Mapping): Returns None if no environment is active. """ - if "VIRTUAL_ENV" not in builtins.__xonsh__.env: + env = builtins.__xonsh__.env + if not env["VIRTUAL_ENV"]: return - env_path = builtins.__xonsh__.env["VIRTUAL_ENV"] + env_path = env["VIRTUAL_ENV"] if env_path.startswith(self.venvdir): name = env_path[len(self.venvdir) :] if name[0] in "/\\": @@ -354,7 +355,7 @@ class Vox(collections.abc.Mapping): """ env = builtins.__xonsh__.env ve = self[name] - if "VIRTUAL_ENV" in env: + if env["VIRTUAL_ENV"]: self.deactivate() type(self).oldvars = {"PATH": list(env["PATH"])} @@ -370,7 +371,7 @@ class Vox(collections.abc.Mapping): Deactivate the active virtual environment. Returns its name. """ env = builtins.__xonsh__.env - if "VIRTUAL_ENV" not in env: + if not env["VIRTUAL_ENV"]: raise NoEnvironmentActive("No environment currently active.") env_name = self.active() @@ -380,7 +381,7 @@ class Vox(collections.abc.Mapping): env[k] = v del type(self).oldvars - env.pop("VIRTUAL_ENV") + del env["VIRTUAL_ENV"] events.vox_on_deactivate.fire(name=env_name, path=self[env_name].env) return env_name