| 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 """Findit for crash (ClusterFuzz & Fracas/Chromecrash) configuration.""" | 5 """Findit for crash (ClusterFuzz & Fracas/Chromecrash) configuration.""" |
| 6 | 6 |
| 7 import re | 7 import re |
| 8 | 8 |
| 9 from google.appengine.ext import ndb | 9 from google.appengine.ext import ndb |
| 10 | 10 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 def ClearCache(self): | 104 def ClearCache(self): |
| 105 self.cached_component_classifier = None | 105 self.cached_component_classifier = None |
| 106 | 106 |
| 107 @property | 107 @property |
| 108 def compiled_component_classifier(self): | 108 def compiled_component_classifier(self): |
| 109 """Returns the component classifier with all re patterns compiled.""" | 109 """Returns the component classifier with all re patterns compiled.""" |
| 110 if self.cached_component_classifier is None and self.component_classifier: | 110 if self.cached_component_classifier is None and self.component_classifier: |
| 111 compiled_path_function_component = [] | 111 compiled_path_function_component = [] |
| 112 for path, function, component in self.component_classifier[ | 112 for path, function, component in self.component_classifier[ |
| 113 'path_function_component']: | 113 'path_function_component']: |
| 114 # TODO(wrengr): build Component objects here, rather than later. |
| 114 compiled_path_function_component.append( | 115 compiled_path_function_component.append( |
| 115 [re.compile(path), | 116 [re.compile(path), |
| 116 re.compile(function) if function else None, | 117 re.compile(function) if function else None, |
| 117 component]) | 118 component]) |
| 118 | 119 |
| 119 self.cached_component_classifier = { | 120 self.cached_component_classifier = { |
| 120 'top_n': self.component_classifier['top_n'], | 121 'top_n': self.component_classifier['top_n'], |
| 121 'path_function_component': compiled_path_function_component | 122 'path_function_component': compiled_path_function_component |
| 122 } | 123 } |
| 123 | 124 |
| 124 return self.cached_component_classifier | 125 return self.cached_component_classifier |
| 125 | 126 |
| 126 def GetClientConfig(self, client_id): | 127 def GetClientConfig(self, client_id): |
| 127 """Gets client specific config using client_id.""" | 128 """Gets client specific config using client_id.""" |
| 128 if client_id == CrashClient.FRACAS: | 129 if client_id == CrashClient.FRACAS: |
| 129 return self.fracas | 130 return self.fracas |
| 130 elif client_id == CrashClient.CRACAS: # pragma: no cover. | 131 elif client_id == CrashClient.CRACAS: # pragma: no cover. |
| 131 # TODO(katesonia): Add crash config of cracas. | 132 # TODO(katesonia): Add crash config of cracas. |
| 132 return None | 133 return None |
| 133 elif client_id == CrashClient.CLUSTERFUZZ: # pragma: no cover. | 134 elif client_id == CrashClient.CLUSTERFUZZ: # pragma: no cover. |
| 134 # TODO(katesonia): Add crash config of clusterfuzz. | 135 # TODO(katesonia): Add crash config of clusterfuzz. |
| 135 return None | 136 return None |
| 136 | 137 |
| 137 return None | 138 return None |
| OLD | NEW |