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

Side by Side Diff: tools/security/check_message_owners.py

Issue 138033013: Add script to tools/security to check consistency of message file owners. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: main() return value Created 6 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Make sure all of the per-file *_messages.h OWNERS are consistent"""
7
8 import os
9 import re
10 import sys
11
12 def main():
13 file_path = os.path.dirname(__file__);
14 root_dir = os.path.abspath(os.path.join(file_path, '..', '..'))
15 owners = collect_owners(root_dir)
16 all_owners = get_all_owners(owners)
17 print_missing_owners(owners, all_owners)
18 return 0
19
20 def collect_owners(root_dir):
21 result = {}
22 for root, dirs, files in os.walk(root_dir):
23 if "OWNERS" in files:
24 owner_file_path = os.path.join(root, "OWNERS")
25 owner_set = extract_owners_from_file(owner_file_path)
26 if owner_set:
27 result[owner_file_path] = owner_set
28 return result
29
30 def extract_owners_from_file(owner_file_path):
31 result = set()
32 regexp = re.compile('^per-file.*_messages[^=]*=\s*(.*)@([^#]*)')
33 with open(owner_file_path) as f:
34 for line in f:
35 match = regexp.match(line)
36 if match:
37 result.add(match.group(1).strip())
38 return result
39
40 def get_all_owners(owner_dict):
41 result = set()
42 for key in owner_dict:
43 result = result.union(owner_dict[key])
44 return result
45
46 def print_missing_owners(owner_dict, owner_set):
47 for key in owner_dict:
48 for owner in owner_set:
49 if not owner in owner_dict[key]:
50 print key + " is missing " + owner
51
52 if '__main__' == __name__:
53 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698