Chromium Code Reviews| Index: chrome/common/extensions/docs/server2/resource_fetcher.py |
| diff --git a/chrome/common/extensions/docs/server2/resource_fetcher.py b/chrome/common/extensions/docs/server2/resource_fetcher.py |
| index 57ea230d5efee4cb0b207892107db622dad8964c..2fa5bd52b02bc7e8832bc06ed3a61aec48ccde8e 100644 |
| --- a/chrome/common/extensions/docs/server2/resource_fetcher.py |
| +++ b/chrome/common/extensions/docs/server2/resource_fetcher.py |
| @@ -2,12 +2,15 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| +import logging |
| +import os |
| + |
| SUBVERSION_URL = 'http://src.chromium.org/viewvc/chrome/' |
| TRUNK_URL = SUBVERSION_URL + 'trunk/' |
| BRANCH_URL = SUBVERSION_URL + 'branches/' |
| class SubversionFetcher(object): |
| - """Class to fetch code from src.chromium.org. |
| + """Class to fetch docs from src.chromium.org. |
|
Aaron Boodman
2012/06/02 07:50:22
It will fetch lots of things. How about s/docs/res
cduvall
2012/06/02 19:12:05
Done.
|
| """ |
| def __init__(self, urlfetch): |
| self.urlfetch = urlfetch |
| @@ -21,3 +24,21 @@ class SubversionFetcher(object): |
| url = self._GetURLFromBranch(branch) + path |
| result = self.urlfetch.fetch(url) |
| return result |
| + |
| +class LocalFetcher(object): |
|
Aaron Boodman
2012/06/02 07:50:22
Each class should typically be in a separate file
cduvall
2012/06/02 19:12:05
Done.
|
| + """Class to fetch docs from local filesystem. |
| + """ |
| + class _Resource(object): |
| + def __init__(self): |
|
Aaron Boodman
2012/06/02 07:50:22
It seems like it would be more robust to pass in a
cduvall
2012/06/02 19:12:05
Done.
|
| + self.content = '' |
| + self.headers = {} |
| + |
| + def _ReadFile(self, filename): |
| + with open(filename, 'r') as f: |
| + return f.read() |
| + |
| + def FetchResource(self, branch, path): |
| + result = self._Resource() |
| + logging.info('Reading: ' + path) |
| + result.content = self._ReadFile(path) |
| + return result |