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

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

Issue 10704252: Extensions Docs Server: Internal file system (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed up 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/samples_data_source.py
diff --git a/chrome/common/extensions/docs/server2/samples_data_source.py b/chrome/common/extensions/docs/server2/samples_data_source.py
index 76fbbac0963644ed633e0eb99e228b7fcf7ee855..c8e7fc4d0387711ede2e859a6181e8c34c64fce4 100644
--- a/chrome/common/extensions/docs/server2/samples_data_source.py
+++ b/chrome/common/extensions/docs/server2/samples_data_source.py
@@ -13,31 +13,32 @@ class SamplesDataSource(object):
self._cache = cache_builder.build(self._MakeSamplesList)
self._samples_path = samples_path
- def _GetApiItems(self, api_items, js_file):
- return set(re.findall('(chrome\.[a-zA-Z0-9\.]+)',
- self._fetcher.FetchResource(js_file).content))
+ def _GetApiItems(self, js_file):
+ return set(re.findall('(chrome\.[a-zA-Z0-9\.]+)', js_file))
def _MakeApiLink(self, prefix, item):
api, name = item.replace('chrome.', '').split('.', 1)
return api + '.html#' + prefix + '-' + name
def _GetDataFromManifest(self, path):
- manifest = self._fetcher.FetchResource(path + '/manifest.json').content
+ manifest_path = path + '/manifest.json'
+ manifest = self._fetcher.Read([manifest_path]).Get()[manifest_path]
manifest_json = json.loads(manifest)
return (manifest_json.get('name'), manifest_json.get('description'))
def _MakeSamplesList(self, files):
samples_list = []
- for filename in files:
+ for filename in sorted(files):
if filename.rsplit('/')[-1] != 'manifest.json':
continue
# This is a little hacky, but it makes a sample page.
sample_path = filename.rsplit('/', 1)[-2]
sample_files = filter(lambda x: x.startswith(sample_path + '/'), files)
- api_items = set([])
- for file_ in sample_files:
- if file_.endswith('.js'):
- api_items.update(self._GetApiItems(api_items, file_))
+ js_files = filter(lambda x: x.endswith('.js'), sample_files)
+ js_contents = self._fetcher.Read(js_files).Get()
+ api_items = set()
+ for js in js_contents.values():
+ api_items.update(self._GetApiItems(js))
api_calls = []
for item in api_items:
@@ -68,4 +69,4 @@ class SamplesDataSource(object):
return self.get(key)
def get(self, key):
- return self._cache.getFromFileListing('docs/' + self._samples_path, True)
+ return self._cache.GetFromFileListing(self._samples_path + '/')

Powered by Google App Engine
This is Rietveld 408576698