-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScoper.py
More file actions
72 lines (50 loc) · 2.17 KB
/
Copy pathScoper.py
File metadata and controls
72 lines (50 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from TargetMethod import TargetMethod
def add_root_path(method_objects, commit_messages):
new_method_objects = {}
for pseudo_path, value in method_objects.items():
for item in commit_messages:
if pseudo_path in item:
new_method_objects[item] = {'Methods': []}
for key, methods in value.items():
for method in methods:
method.repo_path = item
new_method_objects[item]['Methods'].append(method)
break
return new_method_objects
def get_targets(method_list, target_methods, type):
for package, value in method_list[type]['Methods'].items():
for class_name, methods in value.items():
for method_dict in methods:
target = TargetMethod(method_dict['method_name'])
target.return_type = method_dict['return_type']
target.class_name = class_name
target.package_name = package
target.kind = type
if len(method_dict['parameters']) > 0 and method_dict['parameters'][0] != '':
target.parameters = method_dict['parameters']
target_methods.append(target)
return target_methods
def sort_by_class(target_methods):
method_dict = {}
for item in target_methods:
pseudo_path = item.pseudo_path()
if not (pseudo_path in method_dict):
method_dict[pseudo_path] = {'Methods': [item]}
else:
method_dict[pseudo_path]['Methods'].append(item)
return method_dict
def clean_methods(methods):
keys = list(methods.keys())
for path in keys:
if '/icu' in path:
del methods[path]
return methods
def scope(method_items):
target_methods = []
target_methods = get_targets(method_items, target_methods, 'Removed')
target_methods = get_targets(method_items, target_methods, 'Added')
target_methods = get_targets(method_items, target_methods, 'Changed')
target_methods = get_targets(method_items, target_methods, 'Deprecated')
methods = sort_by_class(target_methods)
methods = clean_methods(methods)
return methods