| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from slave import recipe_api | 5 from slave import recipe_api |
| 6 from slave import recipe_util | 6 from slave import recipe_util |
| 7 | 7 |
| 8 class StepApi(recipe_api.RecipeApi): | 8 class StepApi(recipe_api.RecipeApi): |
| 9 def __init__(self, *args, **kwargs): | 9 def __init__(self, **kwargs): |
| 10 super(StepApi, self).__init__(**kwargs) |
| 10 self._auto_resolve_conflicts = False | 11 self._auto_resolve_conflicts = False |
| 11 self._name_function = None | 12 self._name_function = None |
| 12 self._step_names = {} | 13 self._step_names = {} |
| 13 super(StepApi, self).__init__(*args, **kwargs) | |
| 14 | 14 |
| 15 # Making these properties makes them show up in show_me_the_modules, | 15 # Making these properties makes them show up in show_me_the_modules, |
| 16 # and also makes it clear that they are intended to be mutated. | 16 # and also makes it clear that they are intended to be mutated. |
| 17 @property | 17 @property |
| 18 def auto_resolve_conflicts(self): | 18 def auto_resolve_conflicts(self): |
| 19 """Automatically resolve step name conflicts.""" | 19 """Automatically resolve step name conflicts.""" |
| 20 return self._auto_resolve_conflicts | 20 return self._auto_resolve_conflicts |
| 21 | 21 |
| 22 @auto_resolve_conflicts.setter | 22 @auto_resolve_conflicts.setter |
| 23 def auto_resolve_conflicts(self, val): | 23 def auto_resolve_conflicts(self, val): |
| (...skipping 26 matching lines...) Expand all Loading... |
| 50 step_count = self._step_names.setdefault(name, 0) + 1 | 50 step_count = self._step_names.setdefault(name, 0) + 1 |
| 51 self._step_names[name] = step_count | 51 self._step_names[name] = step_count |
| 52 if step_count > 1: | 52 if step_count > 1: |
| 53 name = "%s (%d)" % (name, step_count) | 53 name = "%s (%d)" % (name, step_count) |
| 54 kwargs.update({'name': name, 'cmd': cmd}) | 54 kwargs.update({'name': name, 'cmd': cmd}) |
| 55 | 55 |
| 56 schema = self.make_config() | 56 schema = self.make_config() |
| 57 schema.set_val(kwargs) | 57 schema.set_val(kwargs) |
| 58 | 58 |
| 59 return schema.as_jsonish() | 59 return schema.as_jsonish() |
| OLD | NEW |