OLD | NEW |
1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 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 """A database of OWNERS files.""" | 5 """A database of OWNERS files.""" |
6 | 6 |
7 import collections | 7 import collections |
8 import re | 8 import re |
9 | 9 |
10 | 10 |
11 # If this is present by itself on a line, this means that everyone can review. | 11 # If this is present by itself on a line, this means that everyone can review. |
12 EVERYONE = '*' | 12 EVERYONE = '*' |
13 | 13 |
14 | 14 |
15 # Recognizes 'X@Y' email addresses. Very simplistic. | 15 # Recognizes 'X@Y' email addresses. Very simplistic. |
16 BASIC_EMAIL_REGEXP = r'^[\w\-\+\%\.]+\@[\w\-\+\%\.]+$' | 16 BASIC_EMAIL_REGEXP = r'^[\w\-\+\%\.]+\@[\w\-\+\%\.]+$' |
17 | 17 |
18 | 18 |
19 def _assert_is_collection(obj): | 19 def _assert_is_collection(obj): |
20 assert not isinstance(obj, basestring) | 20 assert not isinstance(obj, basestring) |
| 21 # Module 'collections' has no 'Iterable' member |
| 22 # pylint: disable=E1101 |
21 if hasattr(collections, 'Iterable') and hasattr(collections, 'Sized'): | 23 if hasattr(collections, 'Iterable') and hasattr(collections, 'Sized'): |
22 assert (isinstance(obj, collections.Iterable) and | 24 assert (isinstance(obj, collections.Iterable) and |
23 isinstance(obj, collections.Sized)) | 25 isinstance(obj, collections.Sized)) |
24 | 26 |
25 | 27 |
26 class SyntaxErrorInOwnersFile(Exception): | 28 class SyntaxErrorInOwnersFile(Exception): |
27 def __init__(self, path, lineno, msg): | 29 def __init__(self, path, lineno, msg): |
28 super(SyntaxErrorInOwnersFile, self).__init__((path, lineno, msg)) | 30 super(SyntaxErrorInOwnersFile, self).__init__((path, lineno, msg)) |
29 self.path = path | 31 self.path = path |
30 self.lineno = lineno | 32 self.lineno = lineno |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 # short combinations of owners. | 169 # short combinations of owners. |
168 every_owner = set() | 170 every_owner = set() |
169 for f in files: | 171 for f in files: |
170 dirname = self.os_path.dirname(f) | 172 dirname = self.os_path.dirname(f) |
171 while dirname in self.owners_for: | 173 while dirname in self.owners_for: |
172 every_owner |= self.owners_for[dirname] | 174 every_owner |= self.owners_for[dirname] |
173 if self._stop_looking(dirname): | 175 if self._stop_looking(dirname): |
174 break | 176 break |
175 dirname = self.os_path.dirname(dirname) | 177 dirname = self.os_path.dirname(dirname) |
176 return every_owner | 178 return every_owner |
OLD | NEW |