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

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

Issue 10500004: Die build.py, Die: Part 2 (LocalFetcher, Handlebar support, build script) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 7 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/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

Powered by Google App Engine
This is Rietveld 408576698