From 01c60b8e9bfb573231c7409c2c69d58d5444ee2f Mon Sep 17 00:00:00 2001 From: Matth <116471921+mattthhh@users.noreply.github.com> Date: Thu, 13 Jun 2024 10:37:40 +0200 Subject: [PATCH 1/2] Update base.py --- venvctrl/venv/base.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/venvctrl/venv/base.py b/venvctrl/venv/base.py index 6eeb116..0f136cf 100644 --- a/venvctrl/venv/base.py +++ b/venvctrl/venv/base.py @@ -226,6 +226,19 @@ def _find_vpath(self): return match.group(0), match.group(1), count + # If still here then maybe Python 3.12 and change regex + + read_pattern = re.compile(r"""export VIRTUAL_ENV=["'](.*)["']$""") + + with open(self.path, "r") as file_handle: + + for count, line in enumerate(file_handle): + + match = self.read_pattern.match(line) + if match: + + return match.group(0), match.group(1), count + return None, None, None @property From e97844560f887a64aee0361b6e8f77c80674b323 Mon Sep 17 00:00:00 2001 From: Matth <116471921+mattthhh@users.noreply.github.com> Date: Thu, 13 Jun 2024 10:39:33 +0200 Subject: [PATCH 2/2] Update base.py --- venvctrl/venv/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/venvctrl/venv/base.py b/venvctrl/venv/base.py index 0f136cf..f7efa71 100644 --- a/venvctrl/venv/base.py +++ b/venvctrl/venv/base.py @@ -228,13 +228,13 @@ def _find_vpath(self): # If still here then maybe Python 3.12 and change regex - read_pattern = re.compile(r"""export VIRTUAL_ENV=["'](.*)["']$""") + new_read_pattern = re.compile(r"""export VIRTUAL_ENV=["'](.*)["']$""") with open(self.path, "r") as file_handle: for count, line in enumerate(file_handle): - match = self.read_pattern.match(line) + match = new_read_pattern.match(line) if match: return match.group(0), match.group(1), count