OLD | NEW |
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 from api_data_source import APIDataSource | 5 from api_data_source import APIDataSource |
6 from api_list_data_source import APIListDataSource | 6 from api_list_data_source import APIListDataSource |
7 from data_source import DataSource | 7 from data_source import DataSource |
8 from manifest_data_source import ManifestDataSource | 8 from manifest_data_source import ManifestDataSource |
9 from owners_data_source import OwnersDataSource | 9 from owners_data_source import OwnersDataSource |
10 from permissions_data_source import PermissionsDataSource | 10 from permissions_data_source import PermissionsDataSource |
(...skipping 13 matching lines...) Expand all Loading... |
24 'manifest_source': ManifestDataSource, | 24 'manifest_source': ManifestDataSource, |
25 'owners': OwnersDataSource, | 25 'owners': OwnersDataSource, |
26 'partials': PartialDataSource, | 26 'partials': PartialDataSource, |
27 'permissions': PermissionsDataSource, | 27 'permissions': PermissionsDataSource, |
28 'samples': SamplesDataSource, | 28 'samples': SamplesDataSource, |
29 'sidenavs': SidenavDataSource, | 29 'sidenavs': SidenavDataSource, |
30 'strings': StringsDataSource, | 30 'strings': StringsDataSource, |
31 'whatsNew' : WhatsNewDataSource | 31 'whatsNew' : WhatsNewDataSource |
32 } | 32 } |
33 | 33 |
| 34 |
34 assert all(issubclass(cls, DataSource) | 35 assert all(issubclass(cls, DataSource) |
35 for cls in _all_data_sources.itervalues()) | 36 for cls in _all_data_sources.itervalues()) |
36 | 37 |
| 38 |
| 39 def GetDataSourceNames(): |
| 40 return _all_data_sources.keys() |
| 41 |
| 42 |
| 43 def CreateDataSource(name, server_instance, request=None): |
| 44 '''Create a single DataSource by name.''' |
| 45 assert name in _all_data_sources |
| 46 return _all_data_sources[name](server_instance, request) |
| 47 |
| 48 |
37 def CreateDataSources(server_instance, request=None): | 49 def CreateDataSources(server_instance, request=None): |
38 '''Create a dictionary of initialized DataSources. DataSources are | 50 '''Create a dictionary of initialized DataSources. DataSources are |
39 initialized with |server_instance| and |request|. If the DataSources are | 51 initialized with |server_instance| and |request|. If the DataSources are |
40 going to be used for Cron, |request| should be omitted. | 52 going to be used for Refresh, |request| should be omitted. |
41 | 53 |
42 The key of each DataSource is the name the template system will use to access | 54 The key of each DataSource is the name the template system will use to access |
43 the DataSource. | 55 the DataSource. |
44 ''' | 56 ''' |
45 return dict((name, cls(server_instance, request)) | 57 return dict((name, cls(server_instance, request)) |
46 for name, cls in _all_data_sources.iteritems()) | 58 for name, cls in _all_data_sources.iteritems()) |
OLD | NEW |