Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add a way to use exiting env values in extend_env

  • Loading branch information...
commit d9bec51441e236263e297307063e758418f8feee 1 parent d95fc11
Wojciech Bederski wuub authored

Showing 2 changed files with 10 additions and 1 deletion. Show diff stats Hide diff stats

  1. +1 0  .gitignore
  2. +9 1 subprocess_repl.py
1  .gitignore
... ... @@ -0,0 +1 @@
  1 +*.pyc
10 subprocess_repl.py
@@ -33,7 +33,7 @@ def env(self, env, extend_env):
33 33 import os
34 34 updated_env = env if env else os.environ.copy()
35 35 if extend_env:
36   - updated_env.update(extend_env)
  36 + updated_env.update(self.interpolate_extend_env(updated_env, extend_env))
37 37 bytes_env = {}
38 38 for k,v in updated_env.items():
39 39 enc_k = self.encoder(unicode(k))[0]
@@ -41,6 +41,14 @@ def env(self, env, extend_env):
41 41 bytes_env[enc_k] = enc_v
42 42 return bytes_env
43 43
  44 + def interpolate_extend_env(self, env, extend_env):
  45 + """Interpolates (subst) values in extend_env.
  46 + Mostly for path manipulation"""
  47 + new_env = {}
  48 + for key, val in extend_env.items():
  49 + new_env[key] = val.format(**env)
  50 + return new_env
  51 +
44 52 def startupinfo(self):
45 53 startupinfo = None
46 54 if os.name == 'nt':

0 comments on commit d9bec51

Please sign in to comment.
Something went wrong with that request. Please try again.