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

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

Issue 61393002: Docserver: Enable GitHub content providers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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/content_providers.py
diff --git a/chrome/common/extensions/docs/server2/content_providers.py b/chrome/common/extensions/docs/server2/content_providers.py
index 97e9390343284ca793a0945aaf88844f295cacbb..e8bcc073c742156fa104737f25dfdb4e4b6358dd 100644
--- a/chrome/common/extensions/docs/server2/content_providers.py
+++ b/chrome/common/extensions/docs/server2/content_providers.py
@@ -23,9 +23,13 @@ class ContentProviders(object):
Returns ContentProvider instances based on how they're configured there.
'''
- def __init__(self, compiled_fs_factory, host_file_system):
+ def __init__(self,
+ compiled_fs_factory,
+ host_file_system,
+ github_file_system_provider):
self._compiled_fs_factory = compiled_fs_factory
self._host_file_system = host_file_system
+ self._github_file_system_provider = github_file_system_provider
self._cache = compiled_fs_factory.ForJson(host_file_system)
@memoize
@@ -73,12 +77,22 @@ class ContentProviders(object):
if 'chromium' in config:
chromium_config = config['chromium']
if 'dir' not in chromium_config:
- logging.error('"chromium" must have a "dir" property')
+ logging.error('%s: "chromium" must have a "dir" property' % name)
return None
file_system = ChrootFileSystem(self._host_file_system,
chromium_config['dir'])
+ elif 'github' in config:
+ github_config = config['github']
+ if 'owner' not in github_config or 'repo' not in github_config:
+ logging.error('%s: "github" must provide an "owner" and "repo"' % name)
+ return None
+ file_system = self._github_file_system_provider.Create(
+ github_config['owner'], github_config['repo'])
+ if 'dir' in github_config:
+ file_system = ChrootFileSystem(file_system, github_config['dir'])
else:
- logging.error('Content provider type "%s" not supported', type_)
+ logging.error(
+ '%s: content provider type "%s" not supported' % (name, type_))
return None
return ContentProvider(name,

Powered by Google App Engine
This is Rietveld 408576698