Chromium Code Reviews| Index: recipe_modules/context/api.py |
| diff --git a/recipe_modules/context/api.py b/recipe_modules/context/api.py |
| index 4f9b9d4beaebfc1f2250b3e76d99c333d1f07eb4..619b96e6a6883cfd24de92dbe2c26bc701c941a3 100644 |
| --- a/recipe_modules/context/api.py |
| +++ b/recipe_modules/context/api.py |
| @@ -198,31 +198,34 @@ class ContextApi(RecipeApi): |
| @property |
| def env(self): |
| - """Returns modifications to the environment. |
| + """Returns string modifications to the environment. |
| By default this is empty; There's no facility to observe the program's |
| startup environment. If you want to pass data to the recipe, it should be |
| done with properties. |
| + This will return the string modifications made to the environment. For |
| + prefix modifications, use "env_prefixes". |
| + |
| Returns (dict) - The env-key -> value mapping of current environment |
| modifications. |
| """ |
| # TODO(iannucci): store env in an immutable way to avoid excessive copies. |
| # TODO(iannucci): handle case-insensitive keys on windows |
| - def parts(ev): |
| - for p in ev.prefixes: |
| - yield str(p) |
| - if ev.value: |
| - yield ev.value |
| - |
| - ret = {} |
| - for k, ev in self._env[-1].iteritems(): |
| - if ev.value is None: |
| - ret[k] = None |
| - else: |
| - ret[k] = self.m.path.pathsep.join(parts(ev)) |
| + return {k: v.value for k, v in self._env[-1].iteritems()} |
| + |
| + @property |
| + def env_prefixes(self): |
|
iannucci
2017/06/09 04:47:45
I was actually thinking of storing these as separa
dnj
2017/06/09 04:50:33
I think that this might be a better API - less thi
|
| + """Returns Path prefix modifications to the environment. |
| + |
| + This will return a mapping of environment key to Path tuple for Path |
| + prefixes registered with the environment. |
| - return ret |
| + Returns (dict) - The env-key -> value(Path) mapping of current environment |
| + prefix modifications. |
| + """ |
| + return {k: v.prefixes for k, v in self._env[-1].iteritems() |
| + if v.prefixes} |
| @property |
| def infra_step(self): |
| @@ -264,5 +267,5 @@ class ContextApi(RecipeApi): |
| paths (...Path): The list of paths to prefix. |
| """ |
| for i, path in enumerate(paths): |
| - check_type('path element %d' % (i,), path, Path) |
| + check_type('path element %d' % (i,), path, (Path, str)) |
| return _EnvPathComponent(paths=paths) |