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

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

Issue 10545043: Extensions docs server: Design changes, partial template support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made suggested changes Created 8 years, 6 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 7d80170c21d042c182998537a630d4545422c229..d36dfa78726efffd48fdac18cbd693428109e5ec 100644
--- a/chrome/common/extensions/docs/server2/local_fetcher.py
+++ b/chrome/common/extensions/docs/server2/local_fetcher.py
@@ -9,20 +9,21 @@ class LocalFetcher(object):
"""Class to fetch resources from local filesystem.
"""
def __init__(self, base_path):
- self.base_path = base_path
+ self._base_path = self._ConvertToFilepath(base_path)
+
+ def _ConvertToFilepath(self, path):
+ return path.replace('/', os.sep)
class _Resource(object):
- def __init__(self):
- self.content = ''
+ def __init__(self, content):
+ self.content = content
self.headers = {}
def _ReadFile(self, filename):
- with open(filename, 'r') as f:
+ path = os.path.join(self._base_path, filename)
+ logging.info('Reading: ' + path)
+ with open(path, 'r') as f:
return f.read()
- def FetchResource(self, branch, path):
- real_path = os.path.join(*path.split('/'))
- result = self._Resource()
- logging.info('Reading: ' + os.path.join(self.base_path, real_path))
- result.content = self._ReadFile(os.path.join(self.base_path, real_path))
- return result
+ def FetchResource(self, path):
+ return self._Resource(self._ReadFile(self._ConvertToFilepath(path)))

Powered by Google App Engine
This is Rietveld 408576698