| OLD | NEW |
| 1 # Copyright 2015 The LUCI Authors. All rights reserved. | 1 # Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import collections | 5 import collections |
| 6 import copy | 6 import copy |
| 7 import json | 7 import json |
| 8 import operator | 8 import operator |
| 9 | 9 |
| 10 | 10 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 """Raised when a non-existent attributed is accessed on a StepData object.""" | 162 """Raised when a non-existent attributed is accessed on a StepData object.""" |
| 163 def __init__(self, step, attr): | 163 def __init__(self, step, attr): |
| 164 self.step = step | 164 self.step = step |
| 165 self.attr = attr | 165 self.attr = attr |
| 166 message = ('The recipe attempted to access missing step data "%s" for step ' | 166 message = ('The recipe attempted to access missing step data "%s" for step ' |
| 167 '"%s". Please examine that step for errors.' % (attr, step)) | 167 '"%s". Please examine that step for errors.' % (attr, step)) |
| 168 super(StepDataAttributeError, self).__init__(message) | 168 super(StepDataAttributeError, self).__init__(message) |
| 169 | 169 |
| 170 | 170 |
| 171 class StepData(object): | 171 class StepData(object): |
| 172 def __init__(self, step, retcode): | 172 def __init__(self, step_config, retcode): |
| 173 self._step_config = step_config |
| 173 self._retcode = retcode | 174 self._retcode = retcode |
| 174 self._step = step | |
| 175 | 175 |
| 176 self._presentation = StepPresentation() | 176 self._presentation = StepPresentation() |
| 177 self.abort_reason = None | 177 self.abort_reason = None |
| 178 | 178 |
| 179 @property | 179 @property |
| 180 def step(self): | 180 def step(self): |
| 181 return copy.deepcopy(self._step) | 181 return dict((k, v) for k, v in self._step_config._asdict().iteritems() if v) |
| 182 | 182 |
| 183 @property | 183 @property |
| 184 def retcode(self): | 184 def retcode(self): |
| 185 return self._retcode | 185 return self._retcode |
| 186 | 186 |
| 187 @property | 187 @property |
| 188 def presentation(self): | 188 def presentation(self): |
| 189 return self._presentation | 189 return self._presentation |
| 190 | 190 |
| 191 def __getattr__(self, name): | 191 def __getattr__(self, name): |
| 192 raise StepDataAttributeError(self._step['name'], name) | 192 raise StepDataAttributeError(self._step_config.name, name) |
| OLD | NEW |