| 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
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..cddb8881988e1e7273e270fb78d7495a7f5ac58b
|
| --- /dev/null
|
| +++ b/chrome/common/extensions/docs/server2/local_fetcher.py
|
| @@ -0,0 +1,27 @@
|
| +# Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +import logging
|
| +import os
|
| +
|
| +class LocalFetcher(object):
|
| + """Class to fetch resources from local filesystem.
|
| + """
|
| + def __init__(self, base_path):
|
| + self.base_path = base_path
|
| +
|
| + class _Resource(object):
|
| + def __init__(self):
|
| + 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: ' + os.path.join(self.base_path, path))
|
| + result.content = self._ReadFile(os.path.join(self.base_path, path))
|
| + return result
|
|
|