Chromium Code Reviews| Index: chrome/common/extensions/docs/server2/subversion_fetcher.py |
| diff --git a/chrome/common/extensions/docs/server2/subversion_fetcher.py b/chrome/common/extensions/docs/server2/subversion_fetcher.py |
| index b9d881a810fee4c12c21f7e6118777871c9b7f5c..ac246049662b8affc40ce4af678d6bb9058d4fad 100644 |
| --- a/chrome/common/extensions/docs/server2/subversion_fetcher.py |
| +++ b/chrome/common/extensions/docs/server2/subversion_fetcher.py |
| @@ -2,6 +2,8 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| +import xml.dom.minidom as xml |
| + |
| SUBVERSION_URL = 'http://src.chromium.org/chrome' |
| TRUNK_URL = SUBVERSION_URL + '/trunk' |
| BRANCH_URL = SUBVERSION_URL + '/branches' |
| @@ -18,5 +20,28 @@ class SubversionFetcher(object): |
| return TRUNK_URL + '/src' |
| return BRANCH_URL + '/' + branch + '/src' |
| + def _ListDir(self, directory): |
| + dom = xml.parseString(directory) |
| + files = map(lambda x: x.childNodes[0].data, dom.getElementsByTagName('a')) |
| + if '..' in files: |
| + files.remove('..') |
|
not at google - send to devlin
2012/07/12 00:22:48
I presume it doesn't also return '.'
cduvall
2012/07/12 01:51:23
Correct.
|
| + return files |
| + |
| + def _RecursiveList(self, files, base): |
| + all_files = [] |
| + for filename in files: |
| + if filename.endswith('/'): |
| + dir_name = base + '/' + filename.split('/')[-2] |
| + all_files.extend(self.FetchDirectory(dir_name).content) |
| + else: |
| + all_files.append(base + '/' + filename) |
| + return all_files |
| + |
| + def FetchDirectory(self, path): |
|
not at google - send to devlin
2012/07/12 00:22:48
Ditto, change name, make recursive an option.
cduvall
2012/07/12 01:51:23
Done.
|
| + result = self._url_fetcher.fetch(self._base_path + '/' + path) |
| + result.content = self._RecursiveList(self._ListDir(result.content), path) |
| + return result |
| + |
| def FetchResource(self, path): |
| return self._url_fetcher.fetch(self._base_path + '/' + path) |
| + |