Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8181)

Unified Diff: chrome/common/extensions/docs/server2/subversion_fetcher.py

Issue 10689144: Extensions Docs Server: Samples zip files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed zips Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..f17a65cebfb812fcf8b4f6d9bf2696661e52610b 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,29 @@ 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'))
not at google - send to devlin 2012/07/12 07:06:29 I think the "pythonic" way of doing map() is usual
cduvall 2012/07/12 18:09:02 Done.
+ if '..' in files:
+ files.remove('..')
+ 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.ListDirectory(dir_name).content)
not at google - send to devlin 2012/07/12 07:06:29 need to pass recursive=True here? Or call _Recurs
cduvall 2012/07/12 18:09:02 Done.
+ else:
+ all_files.append(base + '/' + filename)
+ return all_files
+
+ def ListDirectory(self, path, recursive=False):
+ result = self._url_fetcher.fetch(self._base_path + '/' + path)
not at google - send to devlin 2012/07/12 07:06:29 I don't see how this works, doesn't this return HT
cduvall 2012/07/12 18:09:02 Done.
+ if recursive:
+ result.content = self._RecursiveList(self._ListDir(result.content), path)
+ return result
+
def FetchResource(self, path):
return self._url_fetcher.fetch(self._base_path + '/' + path)
+

Powered by Google App Engine
This is Rietveld 408576698