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

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: 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..6bb74d10ddad70bafaf2e5e1723cfbd46186d4c7 100644
--- a/chrome/common/extensions/docs/server2/local_fetcher.py
+++ b/chrome/common/extensions/docs/server2/local_fetcher.py
@@ -4,6 +4,17 @@
import os
+def _MakeSubversionDir(path):
+ """This function is necessary to make the output of a LocalFetcher match what
+ a SubversionFetcher would give.
not at google - send to devlin 2012/07/11 00:35:09 I think this will be unnecessary if listing files
cduvall 2012/07/11 20:56:30 Done.
+ """
+ page = '<title>Local ' + os.path.join(*path.split('/')) + '</title>'
+ for filename in os.listdir(path):
+ if os.path.isdir(os.path.join(path, filename)):
+ filename += '/'
+ page += '\n<a>' + filename + '</a>'
+ return page
+
class LocalFetcher(object):
"""Class to fetch resources from local filesystem.
"""
@@ -22,6 +33,8 @@ class LocalFetcher(object):
def _ReadFile(self, filename):
path = os.path.join(self._base_path, filename)
+ if os.path.isdir(path):
+ return _MakeSubversionDir(path)
with open(path, 'r') as f:
return f.read()

Powered by Google App Engine
This is Rietveld 408576698