Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1350)

Unified Diff: recipe_modules/context/api.py

Issue 2920223011: [context] fix treatment of None in env. (Closed)
Patch Set: really fix it Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | recipe_modules/context/tests/env.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_modules/context/api.py
diff --git a/recipe_modules/context/api.py b/recipe_modules/context/api.py
index b102ef05b3e63ab0cf3d9847207c958013e9ca80..4f9b9d4beaebfc1f2250b3e76d99c333d1f07eb4 100644
--- a/recipe_modules/context/api.py
+++ b/recipe_modules/context/api.py
@@ -45,8 +45,10 @@ def check_type(name, var, expect):
_EnvPathComponent = collections.namedtuple('_EnvPathComponent', (
'paths',))
+# prefixes is a list of strings
+# value is either a string or None
_EnvValue = collections.namedtuple('_EnvValue', (
- 'prefixes', 'str'))
+ 'prefixes', 'value'))
class ContextApi(RecipeApi):
@@ -151,10 +153,10 @@ class ContextApi(RecipeApi):
new = dict(self._env[-1])
for k, v in env.iteritems():
k = str(k)
- ev = new.get(k)
- if ev is None:
- ev = _EnvValue(prefixes=(), str=None)
- if v is not None:
+ if v is None:
+ ev = _EnvValue(prefixes=(), value=None)
+ else:
+ ev = new.get(k, _EnvValue(prefixes=(), value=''))
if isinstance(v, _EnvPathComponent):
ev = ev._replace(prefixes=v.paths+ev.prefixes)
else:
@@ -173,7 +175,7 @@ class ContextApi(RecipeApi):
except Exception:
raise ValueError(('Invalid %%-formatting parameter in envvar, '
'only %%(ENVVAR)s allowed: %r') % (v,))
- ev = ev._replace(str=v)
+ ev = ev._replace(value=v)
new[k] = ev
self._env.append(new)
to_pop.append(self._env)
@@ -210,11 +212,17 @@ class ContextApi(RecipeApi):
def parts(ev):
for p in ev.prefixes:
yield str(p)
- if ev.str is not None:
- yield ev.str
+ if ev.value:
+ yield ev.value
- return {k: self.m.path.pathsep.join(parts(ev))
- for k, ev in self._env[-1].iteritems()}
+ 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 ret
@property
def infra_step(self):
« no previous file with comments | « no previous file | recipe_modules/context/tests/env.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698