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.
6 """Make sure all of the per-file *_messages.h OWNERS are consistent"""
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
)
20 def collect_owners(root_dir
):
22 for root
, dirs
, files
in os
.walk(root_dir
):
24 owner_file_path
= os
.path
.join(root
, "OWNERS")
25 owner_set
= extract_owners_from_file(owner_file_path
)
27 result
[owner_file_path
] = owner_set
30 def extract_owners_from_file(owner_file_path
):
32 regexp
= re
.compile('^per-file.*_messages[^=]*=\s*(.*)@([^#]*)')
33 with
open(owner_file_path
) as f
:
35 match
= regexp
.match(line
)
37 result
.add(match
.group(1).strip())
40 def get_all_owners(owner_dict
):
42 for key
in owner_dict
:
43 result
= result
.union(owner_dict
[key
])
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
52 if '__main__' == __name__
: