| 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 import logging | 5 import logging |
| 6 | 6 |
| 7 from crash.occurrence import RankByOccurrence | 7 from crash.occurrence import RankByOccurrence |
| 8 from crash.type_enums import CallStackLanguageType | 8 from crash.type_enums import CallStackLanguageType |
| 9 from model.crash.crash_config import CrashConfig | 9 from model.crash.crash_config import CrashConfig |
| 10 | 10 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 return (weight, index) | 100 return (weight, index) |
| 101 | 101 |
| 102 rank_function = _RankFunctionForJava | 102 rank_function = _RankFunctionForJava |
| 103 | 103 |
| 104 top_n_frames = self.project_classifier_config['top_n'] | 104 top_n_frames = self.project_classifier_config['top_n'] |
| 105 # If ``results`` are available, we use the projects from there since | 105 # If ``results`` are available, we use the projects from there since |
| 106 # they're more reliable than the ones from the ``crash_stack``. | 106 # they're more reliable than the ones from the ``crash_stack``. |
| 107 if results: | 107 if results: |
| 108 classes = map(self.GetClassFromResult, results[:top_n_frames]) | 108 classes = map(self.GetClassFromResult, results[:top_n_frames]) |
| 109 else: | 109 else: |
| 110 classes = map(self.GetClassFromStackFrame, crash_stack[:top_n_frames]) | 110 classes = map(self.GetClassFromStackFrame, |
| 111 crash_stack.frames[:top_n_frames]) |
| 111 | 112 |
| 112 # Since we're only going to return the highest-ranked class, might | 113 # Since we're only going to return the highest-ranked class, might |
| 113 # as well set ``max_classes`` to 1. | 114 # as well set ``max_classes`` to 1. |
| 114 projects = RankByOccurrence(classes, 1, rank_function=rank_function) | 115 projects = RankByOccurrence(classes, 1, rank_function=rank_function) |
| 115 | 116 |
| 116 if projects: | 117 if projects: |
| 117 return projects[0] | 118 return projects[0] |
| 118 | 119 |
| 119 logging.warning('ProjectClassifier.Classify: no projects found.') | 120 logging.warning('ProjectClassifier.Classify: no projects found.') |
| 120 return '' | 121 return '' |
| OLD | NEW |