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

Unified Diff: recipe_engine/util.py

Issue 1773273003: Make output placeholders like json.output index-able by name. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/recipes-py@master
Patch Set: Rebase. Created 4 years, 9 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 | « recipe_engine/step_runner.py ('k') | recipe_modules/json/api.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_engine/util.py
diff --git a/recipe_engine/util.py b/recipe_engine/util.py
index 200e5c8174050e7f33b86ced479f76ca37e70b7e..e877f19bd340c2dcf8284cad75c44070481102e9 100644
--- a/recipe_engine/util.py
+++ b/recipe_engine/util.py
@@ -35,8 +35,12 @@ class ModuleInjectionSite(object):
class Placeholder(object):
"""Base class for command line argument placeholders. Do not use directly."""
- def __init__(self):
- self.name_pieces = None
+ def __init__(self, name=None):
+ if name is not None:
+ assert isinstance(name, basestring), (
+ 'Expect a string name for a placeholder, but got %r' % name)
+ self.name = name
+ self.namespaces = None
@property
def backing_file(self): # pragma: no cover
@@ -51,9 +55,11 @@ class Placeholder(object):
raise NotImplementedError
@property
- def name(self):
- assert self.name_pieces
- return "%s.%s" % self.name_pieces
+ def label(self):
+ if self.name is None:
+ return "%s.%s" % self.namespaces
+ else:
+ return "%s.%s[%s]" % (self.namespaces[0], self.namespaces[1], self.name)
class InputPlaceholder(Placeholder):
@@ -112,7 +118,7 @@ def returns_placeholder(func):
def inner(self, *args, **kwargs):
ret = static_call(self, func, *args, **kwargs)
assert isinstance(ret, Placeholder)
- ret.name_pieces = (self.name, static_name(self, func))
+ ret.namespaces = (self.name, static_name(self, func))
return ret
# prevent this placeholder-returning function from becoming a composite_step.
inner._non_step = True # pylint: disable=protected-access
« no previous file with comments | « recipe_engine/step_runner.py ('k') | recipe_modules/json/api.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698