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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 """Fetch the list of watchers for |paths| | 97 """Fetch the list of watchers for |paths| |
98 | 98 |
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 for name, rule in self._defns.iteritems(): | 108 for name, rule in self._defns.iteritems(): |
108 if name not in self._watchlists: continue | 109 if name not in self._watchlists: continue |
109 rex_str = rule.get('filepath') | 110 rex_str = rule.get('filepath') |
110 if not rex_str: continue | 111 if not rex_str: continue |
111 if re.search(rex_str, path): | 112 if re.search(rex_str, path): |
112 map(watchers.add, self._watchlists[name]) | 113 map(watchers.add, self._watchlists[name]) |
113 return list(watchers) | 114 return list(watchers) |
114 | 115 |
115 | 116 |
116 def main(argv): | 117 def main(argv): |
117 # Confirm that watchlists can be parsed and spew out the watchers | 118 # Confirm that watchlists can be parsed and spew out the watchers |
118 if len(argv) < 2: | 119 if len(argv) < 2: |
119 print "Usage (from the base of repo):" | 120 print "Usage (from the base of repo):" |
120 print " %s [file-1] [file-2] ...." % argv[0] | 121 print " %s [file-1] [file-2] ...." % argv[0] |
121 return 1 | 122 return 1 |
122 wl = Watchlists(os.getcwd()) | 123 wl = Watchlists(os.getcwd()) |
123 watchers = wl.GetWatchersForPaths(argv[1:]) | 124 watchers = wl.GetWatchersForPaths(argv[1:]) |
124 print watchers | 125 print watchers |
125 | 126 |
126 | 127 |
127 if __name__ == '__main__': | 128 if __name__ == '__main__': |
128 main(sys.argv) | 129 main(sys.argv) |
OLD | NEW |