Permalink
Browse files

Add a way to use exiting env values in extend_env

  • Loading branch information...
wuub committed Feb 21, 2012
1 parent d95fc11 commit d9bec51441e236263e297307063e758418f8feee
Showing with 10 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +9 −1 subprocess_repl.py
View
@@ -0,0 +1 @@
+*.pyc
View
@@ -33,14 +33,22 @@ def env(self, env, extend_env):
import os
updated_env = env if env else os.environ.copy()
if extend_env:
- updated_env.update(extend_env)
+ updated_env.update(self.interpolate_extend_env(updated_env, extend_env))
bytes_env = {}
for k,v in updated_env.items():
enc_k = self.encoder(unicode(k))[0]
enc_v = self.encoder(unicode(v))[0]
bytes_env[enc_k] = enc_v
return bytes_env
+ def interpolate_extend_env(self, env, extend_env):
+ """Interpolates (subst) values in extend_env.
+ Mostly for path manipulation"""
+ new_env = {}
+ for key, val in extend_env.items():
+ new_env[key] = val.format(**env)
+ return new_env
+
def startupinfo(self):
startupinfo = None
if os.name == 'nt':

0 comments on commit d9bec51

Please sign in to comment.