OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Watchlists | 6 """Watchlists |
7 | 7 |
8 Watchlists is a mechanism that allow a developer (a "watcher") to watch over | 8 Watchlists is a mechanism that allow a developer (a "watcher") to watch over |
9 portions of code that he is interested in. A "watcher" will be cc-ed to | 9 portions of code that he is interested in. A "watcher" will be cc-ed to |
10 changes that modify that portion of code, thereby giving him an opportunity | 10 changes that modify that portion of code, thereby giving him an opportunity |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 Args: | 99 Args: |
100 paths: [path1, path2, ...] | 100 paths: [path1, path2, ...] |
101 | 101 |
102 Returns: | 102 Returns: |
103 [u1@chromium.org, u2@gmail.com, ...] | 103 [u1@chromium.org, u2@gmail.com, ...] |
104 """ | 104 """ |
105 watchers = set() # A set, to avoid duplicates | 105 watchers = set() # A set, to avoid duplicates |
106 for path in paths: | 106 for path in paths: |
107 path = path.replace(os.sep, '/') | 107 path = path.replace(os.sep, '/') |
108 for name, rule in self._defns.iteritems(): | 108 for name, rule in self._defns.iteritems(): |
109 if name not in self._watchlists: continue | 109 if name not in self._watchlists: |
| 110 continue |
110 rex_str = rule.get('filepath') | 111 rex_str = rule.get('filepath') |
111 if not rex_str: continue | 112 if not rex_str: |
| 113 continue |
112 if re.search(rex_str, path): | 114 if re.search(rex_str, path): |
113 map(watchers.add, self._watchlists[name]) | 115 map(watchers.add, self._watchlists[name]) |
114 return list(watchers) | 116 return list(watchers) |
115 | 117 |
116 | 118 |
117 def main(argv): | 119 def main(argv): |
118 # Confirm that watchlists can be parsed and spew out the watchers | 120 # Confirm that watchlists can be parsed and spew out the watchers |
119 if len(argv) < 2: | 121 if len(argv) < 2: |
120 print "Usage (from the base of repo):" | 122 print "Usage (from the base of repo):" |
121 print " %s [file-1] [file-2] ...." % argv[0] | 123 print " %s [file-1] [file-2] ...." % argv[0] |
122 return 1 | 124 return 1 |
123 wl = Watchlists(os.getcwd()) | 125 wl = Watchlists(os.getcwd()) |
124 watchers = wl.GetWatchersForPaths(argv[1:]) | 126 watchers = wl.GetWatchersForPaths(argv[1:]) |
125 print watchers | 127 print watchers |
126 | 128 |
127 | 129 |
128 if __name__ == '__main__': | 130 if __name__ == '__main__': |
129 main(sys.argv) | 131 main(sys.argv) |
OLD | NEW |