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 (isinstance(obj, collections.Iterable) and | 20 assert not isinstance(obj, basestring) |
21 isinstance(obj, collections.Sized) and | 21 if hasattr(collections, 'Iterable') and hasattr(collections, 'Sized'): |
22 not isinstance(obj, basestring)) | 22 assert (isinstance(obj, collections.Iterable) and |
| 23 isinstance(obj, collections.Sized)) |
23 | 24 |
24 | 25 |
25 class SyntaxErrorInOwnersFile(Exception): | 26 class SyntaxErrorInOwnersFile(Exception): |
26 def __init__(self, path, lineno, msg): | 27 def __init__(self, path, lineno, msg): |
27 super(SyntaxErrorInOwnersFile, self).__init__((path, lineno, msg)) | 28 super(SyntaxErrorInOwnersFile, self).__init__((path, lineno, msg)) |
28 self.path = path | 29 self.path = path |
29 self.lineno = lineno | 30 self.lineno = lineno |
30 self.msg = msg | 31 self.msg = msg |
31 | 32 |
32 def __str__(self): | 33 def __str__(self): |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 # short combinations of owners. | 167 # short combinations of owners. |
167 every_owner = set() | 168 every_owner = set() |
168 for f in files: | 169 for f in files: |
169 dirname = self.os_path.dirname(f) | 170 dirname = self.os_path.dirname(f) |
170 while dirname in self.owners_for: | 171 while dirname in self.owners_for: |
171 every_owner |= self.owners_for[dirname] | 172 every_owner |= self.owners_for[dirname] |
172 if self._stop_looking(dirname): | 173 if self._stop_looking(dirname): |
173 break | 174 break |
174 dirname = self.os_path.dirname(dirname) | 175 dirname = self.os_path.dirname(dirname) |
175 return every_owner | 176 return every_owner |
OLD | NEW |