| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 collections import namedtuple | 5 from collections import namedtuple |
| 6 | 6 |
| 7 | 7 |
| 8 class Culprit(namedtuple('Culprit', | 8 class Culprit(namedtuple('Culprit', |
| 9 ['project', 'components', 'cls', 'regression_range', 'algorithm'])): | 9 ['project', 'components', 'cls', 'regression_range', 'algorithm'])): |
| 10 """The result of successfully identifying the culprit of a crash report. | 10 """The result of successfully identifying the culprit of a crash report. |
| 11 | 11 |
| 12 That is, this is what ``Predator.FindCultprit`` returns. It encapsulates |
| 13 all the information predator discovered during its various analyses. |
| 14 |
| 12 Args: | 15 Args: |
| 13 project (str): the most-suspected project | 16 project (str): the most-suspected project |
| 14 components (list of str): the suspected crbug components. | 17 components (list of str): the suspected crbug components. |
| 15 cls (list of ??): the suspected CLs. | 18 cls (list of ??): the suspected CLs. |
| 16 regression_range (tuple): a pair of the last-good and first-bad versions. | 19 regression_range (tuple): a pair of the last-good and first-bad versions. |
| 17 algorithm (str): What algorithm was used to produce this object. | 20 algorithm (str): What algorithm was used to produce this object. |
| 18 """ | 21 """ |
| 19 __slots__ = () | 22 __slots__ = () |
| 20 | 23 |
| 21 @property | 24 @property |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } | 85 } |
| 83 For results using git blame without a regression range: { | 86 For results using git blame without a regression range: { |
| 84 'found_suspects': True, | 87 'found_suspects': True, |
| 85 'has_regression_range': False, | 88 'has_regression_range': False, |
| 86 'solution': 'blame', | 89 'solution': 'blame', |
| 87 } | 90 } |
| 88 If nothing is found: { | 91 If nothing is found: { |
| 89 'found_suspects': False, | 92 'found_suspects': False, |
| 90 } | 93 } |
| 91 """ | 94 """ |
| 92 # TODO(wrengr): will this auto-dropping of unnecessary fields cause | |
| 93 # any issues for JSON serialization? | |
| 94 result = {} | 95 result = {} |
| 95 result['found'] = ( | 96 result['found'] = ( |
| 96 bool(self.project) or | 97 bool(self.project) or |
| 97 bool(self.components) or | 98 bool(self.components) or |
| 98 bool(self.cls) or | 99 bool(self.cls) or |
| 99 bool(self.regression_range)) | 100 bool(self.regression_range)) |
| 100 if self.regression_range: | 101 if self.regression_range: |
| 101 result['regression_range'] = self.regression_range | 102 result['regression_range'] = self.regression_range |
| 102 if self.project: | 103 if self.project: |
| 103 result['suspected_project'] = self.project | 104 result['suspected_project'] = self.project |
| 104 if self.components: | 105 if self.components: |
| 105 result['suspected_components'] = self.components | 106 result['suspected_components'] = self.components |
| 106 if self.cls: | 107 if self.cls: |
| 107 result['suspected_cls'] = [cl.ToDict() for cl in self.cls] | 108 result['suspected_cls'] = [cl.ToDict() for cl in self.cls] |
| 108 | 109 |
| 109 tags = { | 110 tags = { |
| 110 'found_suspects': bool(self.cls), | 111 'found_suspects': bool(self.cls), |
| 111 'has_regression_range': bool(self.regression_range), | 112 'has_regression_range': bool(self.regression_range), |
| 112 'found_project': bool(self.project), | 113 'found_project': bool(self.project), |
| 113 'found_components': bool(self.components), | 114 'found_components': bool(self.components), |
| 114 'solution': self.algorithm, | 115 'solution': self.algorithm, |
| 115 } | 116 } |
| 116 | 117 |
| 117 return result, tags | 118 return result, tags |
| OLD | NEW |