From 0920810b016190624b245719ab4a8886b3664182 Mon Sep 17 00:00:00 2001 From: Nabil Ghodbane Date: Wed, 15 Mar 2023 16:22:02 +0100 Subject: [PATCH] add appendVariable method to SalomeContext --- bin/salomeContext.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bin/salomeContext.py b/bin/salomeContext.py index 865b17557..605c9cd16 100755 --- a/bin/salomeContext.py +++ b/bin/salomeContext.py @@ -199,7 +199,7 @@ class SalomeContext: del os.environ[name] # - """Append value to environment variable""" + """Prepend value to environment variable""" def addToVariable(self, name, value, separator=os.pathsep): if value == '': return @@ -213,6 +213,19 @@ class SalomeContext: os.environ[name] = value + separator + env # + """Append a variable""" + def appendVariable(self, name, value, separator=os.pathsep): + if value == '': + return + + value = os.path.expandvars(value) # expand environment variables + env = os.getenv(name, None) + if env is None: + os.environ[name] = value + else: + os.environ[name] = env + separator + value + return + ################################### # This begins the private section # ################################### -- 2.39.2