Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: appengine/findit/crash/component_classifier.py

Issue 2538373003: [Culprit-Finder] Merge lib/ to libs/. (Closed)
Patch Set: . Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 from collections import defaultdict 6 from collections import defaultdict
7 import logging 7 import logging
8 import re 8 import re
9 9
10 from crash.component import Component 10 from crash.component import Component
11 from crash.occurrence import RankByOccurrence 11 from crash.occurrence import RankByOccurrence
12 from lib.gitiles.diff import ChangeType 12 from libs.gitiles.diff import ChangeType
13
13 14
14 class ComponentClassifier(object): 15 class ComponentClassifier(object):
15 """Determines the component of a crash. 16 """Determines the component of a crash.
16 17
17 For example: ['Blink>DOM', 'Blink>HTML']. 18 For example: ['Blink>DOM', 'Blink>HTML'].
18 """ 19 """
19 20
20 def __init__(self, components, top_n): 21 def __init__(self, components, top_n):
21 """Build a classifier for components. 22 """Build a classifier for components.
22 23
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 top_n: number of components assigned to this change log, default is 2 107 top_n: number of components assigned to this change log, default is 2
107 108
108 Returns: 109 Returns:
109 List of components 110 List of components
110 """ 111 """
111 if not change_log: 112 if not change_log:
112 return None 113 return None
113 114
114 classes = map(self.GetClassFromFileChangeInfo, change_log.touched_files) 115 classes = map(self.GetClassFromFileChangeInfo, change_log.touched_files)
115 return RankByOccurrence(classes, top_n, rank_function=lambda x:-len(x)) 116 return RankByOccurrence(classes, top_n, rank_function=lambda x:-len(x))
OLDNEW
« no previous file with comments | « appengine/findit/crash/changelist_classifier.py ('k') | appengine/findit/crash/crash_pipeline.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698