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

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

Issue 10827063: Extensions Docs Server: Pull info from _permission_features.json (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/api_data_source.py
diff --git a/chrome/common/extensions/docs/server2/api_data_source.py b/chrome/common/extensions/docs/server2/api_data_source.py
index 90858cd50740f8e64f94a11c25ffaa8548953f5f..feedf0e1b1264b1ec9e45239c8d6e46fc968cbd5 100644
--- a/chrome/common/extensions/docs/server2/api_data_source.py
+++ b/chrome/common/extensions/docs/server2/api_data_source.py
@@ -16,7 +16,8 @@ class APIDataSource(object):
"""This class fetches and loads JSON APIs from the FileSystem passed in with
|cache_builder|, so the APIs can be plugged into templates.
"""
- def __init__(self, cache_builder, base_path):
+ def __init__(self, cache_builder, file_system, base_path):
+ self._file_system = file_system
self._json_cache = cache_builder.build(self._LoadJsonAPI)
self._idl_cache = cache_builder.build(self._LoadIdlAPI)
self._base_path = base_path
@@ -31,19 +32,34 @@ class APIDataSource(object):
generator = HandlebarDictGenerator(idl_schema.IDLSchema(idl).process()[0])
return generator.Generate()
+ def _GetChannel(self, path):
not at google - send to devlin 2012/07/30 12:43:23 This is getting the Feature, not the Channel ("cha
cduvall 2012/07/30 19:08:29 Done.
+ path = path.replace('experimental_', '')
+ try:
+ perms = json.loads(json_comment_eater.Nom(
+ self._file_system.ReadSingle(
+ self._base_path + '/_permission_features.json')))
not at google - send to devlin 2012/07/30 12:43:23 Could you put the loaded JSON in a cache (like the
cduvall 2012/07/30 19:08:29 Done.
+ return perms.get(path, None)
+ except:
+ return None
+
def __getitem__(self, key):
return self.get(key)
def get(self, key):
path, ext = os.path.splitext(key)
+ api_dict = { 'perms': self._GetChannel(path) }
not at google - send to devlin 2012/07/30 12:43:23 no need to abbr perms
cduvall 2012/07/30 19:08:29 Done.
unix_name = model.UnixName(path)
json_path = unix_name + '.json'
idl_path = unix_name + '.idl'
try:
- return self._json_cache.GetFromFile(self._base_path + '/' + json_path)
+ api_dict.update(
+ self._json_cache.GetFromFile(self._base_path + '/' + json_path))
+ return api_dict
not at google - send to devlin 2012/07/30 12:43:23 looks like this is a job for a helper method...
cduvall 2012/07/30 19:08:29 Done.
except Exception:
try:
- return self._idl_cache.GetFromFile(self._base_path + '/' + idl_path)
+ api_dict.update(
+ self._idl_cache.GetFromFile(self._base_path + '/' + idl_path))
+ return api_dict
except Exception as e:
logging.warn(e)
return None

Powered by Google App Engine
This is Rietveld 408576698