Chromium Code Reviews| Index: recipe_engine/util.py |
| diff --git a/recipe_engine/util.py b/recipe_engine/util.py |
| index 75cd5f9441f5b9eed881ef37bdf4ccedabcaa6e1..49526329d470c1ed4dad722fa26f5b55abbb680f 100644 |
| --- a/recipe_engine/util.py |
| +++ b/recipe_engine/util.py |
| @@ -34,9 +34,12 @@ class ModuleInjectionSite(object): |
| class Placeholder(object): |
| + DEFAULT_ID = object() |
| + |
| """Base class for json placeholders. Do not use directly.""" |
| - def __init__(self): |
| + def __init__(self, id=None): |
|
iannucci
2016/03/10 03:17:42
I think you can do
id=DEFAULT_ID
or maybe
stgao
2016/03/10 20:34:23
No. We can't do that, because subclasses will call
|
| self.name_pieces = None |
| + self.id = id or Placeholder.DEFAULT_ID |
| @property |
| def backing_file(self): # pragma: no cover |
| @@ -68,6 +71,12 @@ class Placeholder(object): |
| assert self.name_pieces |
| return "%s.%s" % self.name_pieces |
| + @property |
| + def id_name(self): |
| + if self.id == self.DEFAULT_ID: |
|
iannucci
2016/03/10 03:17:42
use the `is` keyword for comparison (compares poin
stgao
2016/03/10 20:34:23
Done.
|
| + return self.name |
| + else: |
| + return "%s.%s" % (self.id, self.name) |
| def static_wraps(func): |
| wrapped_fn = func |