From: Nabil Ghodbane Date: Wed, 15 Mar 2023 15:22:02 +0000 (+0100) Subject: add appendVariable method to SalomeContext X-Git-Tag: V9_11_0a1~2^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0920810b016190624b245719ab4a8886b3664182;p=modules%2Fkernel.git add appendVariable method to SalomeContext --- 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 # ###################################