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

Side by Side Diff: chrome/common/extensions/docs/server2/content_providers.py

Issue 68873003: Docserver: Serve docs out of src/ not src/chrome/common/extensions. This allows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix samples 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 from operator import itemgetter 6 from operator import itemgetter
7 import posixpath 7 import posixpath
8 8
9 from chroot_file_system import ChrootFileSystem 9 from chroot_file_system import ChrootFileSystem
10 from content_provider import ContentProvider 10 from content_provider import ContentProvider
11 from extensions_paths import CONTENT_PROVIDERS
11 from future import Gettable, Future 12 from future import Gettable, Future
12 from svn_constants import JSON_PATH
13 from third_party.json_schema_compiler.memoize import memoize 13 from third_party.json_schema_compiler.memoize import memoize
14 14
15 15
16 _CONFIG_PATH = '%s/content_providers.json' % JSON_PATH
17
18
19 class ContentProviders(object): 16 class ContentProviders(object):
20 '''Implements the content_providers.json configuration; see 17 '''Implements the content_providers.json configuration; see
21 chrome/common/extensions/docs/templates/json/content_providers.json for its 18 chrome/common/extensions/docs/templates/json/content_providers.json for its
22 current state and a description of the format. 19 current state and a description of the format.
23 20
24 Returns ContentProvider instances based on how they're configured there. 21 Returns ContentProvider instances based on how they're configured there.
25 ''' 22 '''
26 23
27 def __init__(self, 24 def __init__(self,
28 compiled_fs_factory, 25 compiled_fs_factory,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 path_parts = path.split('/') 59 path_parts = path.split('/')
63 for i in xrange(len(path_parts), -1, -1): 60 for i in xrange(len(path_parts), -1, -1):
64 name_and_config = serve_from_to_config.get('/'.join(path_parts[:i])) 61 name_and_config = serve_from_to_config.get('/'.join(path_parts[:i]))
65 if name_and_config is not None: 62 if name_and_config is not None:
66 return (self._CreateContentProvider(name_and_config[0], 63 return (self._CreateContentProvider(name_and_config[0],
67 name_and_config[1]), 64 name_and_config[1]),
68 '/'.join(path_parts[i:])) 65 '/'.join(path_parts[i:]))
69 return None, path 66 return None, path
70 67
71 def _GetConfig(self): 68 def _GetConfig(self):
72 return self._cache.GetFromFile(_CONFIG_PATH).Get() 69 return self._cache.GetFromFile(CONTENT_PROVIDERS).Get()
73 70
74 def _CreateContentProvider(self, name, config): 71 def _CreateContentProvider(self, name, config):
75 supports_templates = config.get('supportsTemplates', False) 72 supports_templates = config.get('supportsTemplates', False)
76 supports_zip = config.get('supportsZip', False) 73 supports_zip = config.get('supportsZip', False)
77 74
78 if 'chromium' in config: 75 if 'chromium' in config:
79 chromium_config = config['chromium'] 76 chromium_config = config['chromium']
80 if 'dir' not in chromium_config: 77 if 'dir' not in chromium_config:
81 logging.error('%s: "chromium" must have a "dir" property' % name) 78 logging.error('%s: "chromium" must have a "dir" property' % name)
82 return None 79 return None
(...skipping 16 matching lines...) Expand all
99 return ContentProvider(name, 96 return ContentProvider(name,
100 self._compiled_fs_factory, 97 self._compiled_fs_factory,
101 file_system, 98 file_system,
102 supports_templates=supports_templates, 99 supports_templates=supports_templates,
103 supports_zip=supports_zip) 100 supports_zip=supports_zip)
104 101
105 def Cron(self): 102 def Cron(self):
106 futures = [self._CreateContentProvider(name, config).Cron() 103 futures = [self._CreateContentProvider(name, config).Cron()
107 for name, config in self._GetConfig().iteritems()] 104 for name, config in self._GetConfig().iteritems()]
108 return Future(delegate=Gettable(lambda: [f.Get() for f in futures])) 105 return Future(delegate=Gettable(lambda: [f.Get() for f in futures]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698