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

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 uppon https://codereview.chromium.org/1785543004/ 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
Index: recipe_engine/util.py
diff --git a/recipe_engine/util.py b/recipe_engine/util.py
index 1bc3f4e54cfd6935288c60c188ce1e99d58e7575..b19baeb776621acf618ba49a883a732983d74d81 100644
--- a/recipe_engine/util.py
+++ b/recipe_engine/util.py
@@ -36,7 +36,7 @@ class ModuleInjectionSite(object):
class Placeholder(object):
"""Base class for command line argument placeholders. Do not use directly."""
def __init__(self):
- self.name_pieces = None
+ self.namespaces = None
@property
def backing_file(self): # pragma: no cover
@@ -62,9 +62,9 @@ class Placeholder(object):
pass
@property
- def name(self):
- assert self.name_pieces
- return "%s.%s" % self.name_pieces
+ def namespace(self):
+ assert self.namespaces
+ return "%s.%s" % self.namespaces
iannucci 2016/03/12 03:43:55 should we consider a format like "json.output[labe
stgao 2016/03/22 05:58:04 This is handled by the full_name below. Moved it u
class InputPlaceholder(Placeholder):
@@ -77,11 +77,25 @@ class InputPlaceholder(Placeholder):
class OutputPlaceholder(Placeholder):
"""Base class for json/raw_io output placeholders. Do not use directly."""
+
+ def __init__(self, name=None):
+ if name is not None:
+ assert isinstance(name, basestring)
+ self.name = name
+ super(OutputPlaceholder, self).__init__()
+
def result(self, presentation, test):
"""Returned value will be added to the step result."""
pass
result.__doc__ = Placeholder.result.__doc__
+ @property
+ def full_name(self):
+ if self.name is None:
+ return super(OutputPlaceholder, self).namespace
+ else:
+ return "%s.%s" % (self.name, super(OutputPlaceholder, self).namespace)
+
def static_wraps(func):
wrapped_fn = func
@@ -113,7 +127,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

Powered by Google App Engine
This is Rietveld 408576698