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

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

Issue 10689144: Extensions Docs Server: Samples zip files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up and tests 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/local_fetcher.py
diff --git a/chrome/common/extensions/docs/server2/local_fetcher.py b/chrome/common/extensions/docs/server2/local_fetcher.py
index 88b8389ad9642549419cfc7122562cc1c51a5594..b40756bcf1c45a50856808d4166a435461fc0ac8 100644
--- a/chrome/common/extensions/docs/server2/local_fetcher.py
+++ b/chrome/common/extensions/docs/server2/local_fetcher.py
@@ -25,6 +25,24 @@ class LocalFetcher(object):
with open(path, 'r') as f:
return f.read()
+ def ListDirectory(self, directory, recursive=False):
+ """Returns a list of files in the directory with |_base_path| removed.
+ """
+ all_files = []
+ if recursive:
+ for path, subdirs, files in os.walk(
+ os.path.join(self._base_path, self._ConvertToFilepath(directory))):
+ for filename in files:
+ full_path = os.path.join(path, filename)
+ if os.path.isdir(full_path):
+ all_files.append(full_path + '/')
+ else:
+ all_files.append(full_path)
+ else:
+ all_files.extend(os.listdir(os.path.join(self._base_path, directory)))
+ return self._Response(
+ [x.replace(self._base_path + os.sep, '') for x in all_files])
+
def FetchResource(self, path):
# A response object is returned to match the behavior of urlfetch.
# See: developers.google.com/appengine/docs/python/urlfetch/responseobjects

Powered by Google App Engine
This is Rietveld 408576698