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

Unified Diff: recipe_modules/raw_io/api.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: 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_modules/raw_io/api.py
diff --git a/recipe_modules/raw_io/api.py b/recipe_modules/raw_io/api.py
index 10da51a8604cde5de76b972ce0119221fd59911b..95c9242b4ce364a26d9bad7a1e0414ec669220c7 100644
--- a/recipe_modules/raw_io/api.py
+++ b/recipe_modules/raw_io/api.py
@@ -11,12 +11,12 @@ import tempfile
class InputDataPlaceholder(recipe_util.Placeholder):
- def __init__(self, data, suffix):
+ def __init__(self, data, suffix, id=id):
assert isinstance(data, basestring)
self.data = data
self.suffix = suffix
self._backing_file = None
- super(InputDataPlaceholder, self).__init__()
+ super(InputDataPlaceholder, self).__init__(id=id)
@property
def backing_file(self):
@@ -43,11 +43,11 @@ class InputDataPlaceholder(recipe_util.Placeholder):
class OutputDataPlaceholder(recipe_util.Placeholder):
- def __init__(self, suffix, leak_to):
+ def __init__(self, suffix, leak_to, id=None):
self.suffix = suffix
self.leak_to = leak_to
self._backing_file = None
- super(OutputDataPlaceholder, self).__init__()
+ super(OutputDataPlaceholder, self).__init__(id=id)
@property
def backing_file(self):
@@ -81,11 +81,11 @@ class OutputDataPlaceholder(recipe_util.Placeholder):
class OutputDataDirPlaceholder(recipe_util.Placeholder):
- def __init__(self, suffix, leak_to):
+ def __init__(self, suffix, leak_to, id=None):
self.suffix = suffix
self.leak_to = leak_to
self._backing_dir = None
- super(OutputDataDirPlaceholder, self).__init__()
+ super(OutputDataDirPlaceholder, self).__init__(id=id)
@property
def backing_file(self): # pragma: no cover
@@ -131,12 +131,12 @@ class OutputDataDirPlaceholder(recipe_util.Placeholder):
class RawIOApi(recipe_api.RecipeApi):
@recipe_util.returns_placeholder
@staticmethod
- def input(data, suffix=''):
- return InputDataPlaceholder(data, suffix)
+ def input(data, suffix='', id=None):
+ return InputDataPlaceholder(data, suffix, id=id)
@recipe_util.returns_placeholder
@staticmethod
- def output(suffix='', leak_to=None):
+ def output(suffix='', leak_to=None, id=None):
"""Returns a Placeholder for use as a step argument, or for std{out,err}.
If 'leak_to' is None, the placeholder is backed by a temporary file with
@@ -146,11 +146,11 @@ class RawIOApi(recipe_api.RecipeApi):
redirects IO to a file at that path. Once step finishes, the file is
NOT deleted (i.e. it's 'leaking'). 'suffix' is ignored in that case.
"""
- return OutputDataPlaceholder(suffix, leak_to)
+ return OutputDataPlaceholder(suffix, leak_to, id=id)
@recipe_util.returns_placeholder
@staticmethod
- def output_dir(suffix='', leak_to=None):
+ def output_dir(suffix='', leak_to=None, id=None):
"""Returns a directory Placeholder for use as a step argument.
If 'leak_to' is None, the placeholder is backed by a temporary dir with
@@ -160,4 +160,4 @@ class RawIOApi(recipe_api.RecipeApi):
redirects IO to a dir at that path. Once step finishes, the dir is
NOT deleted (i.e. it's 'leaking'). 'suffix' is ignored in that case.
"""
- return OutputDataDirPlaceholder(suffix, leak_to)
+ return OutputDataDirPlaceholder(suffix, leak_to, id=id)

Powered by Google App Engine
This is Rietveld 408576698