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

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

Issue 22824042: Docserver: SidenavDataSource refactor, transition to DataSourceRegistry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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 unified diff | Download patch
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 copy 5 import copy
6 import logging 6 import logging
7 import os 7 import os
8 from collections import defaultdict, Mapping 8 from collections import defaultdict, Mapping
9 9
10 from branch_utility import BranchUtility 10 from branch_utility import BranchUtility
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 self._add_rules_schema = None 555 self._add_rules_schema = None
556 556
557 def SetSamplesDataSourceFactory(self, samples_data_source_factory): 557 def SetSamplesDataSourceFactory(self, samples_data_source_factory):
558 self._samples_data_source_factory = samples_data_source_factory 558 self._samples_data_source_factory = samples_data_source_factory
559 559
560 def SetReferenceResolverFactory(self, ref_resolver_factory): 560 def SetReferenceResolverFactory(self, ref_resolver_factory):
561 self._ref_resolver_factory = ref_resolver_factory 561 self._ref_resolver_factory = ref_resolver_factory
562 562
563 def SetTemplateDataSource(self, template_data_source_factory): 563 def SetTemplateDataSource(self, template_data_source_factory):
564 # This TemplateDataSource is only being used for fetching template data. 564 # This TemplateDataSource is only being used for fetching template data.
565 self._template_data_source = template_data_source_factory.Create(None, '') 565 self._template_data_source = template_data_source_factory.Create(
566 None, '', {})
566 567
567 def Create(self, request, disable_refs=False): 568 def Create(self, request, disable_refs=False):
568 """Create an APIDataSource. |disable_refs| specifies whether $ref's in 569 """Create an APIDataSource. |disable_refs| specifies whether $ref's in
569 APIs being processed by the |ToDict| method of _JSCModel follows $ref's 570 APIs being processed by the |ToDict| method of _JSCModel follows $ref's
570 in the API. This prevents endless recursion in ReferenceResolver. 571 in the API. This prevents endless recursion in ReferenceResolver.
571 """ 572 """
572 if self._samples_data_source_factory is None: 573 if self._samples_data_source_factory is None:
573 # Only error if there is a request, which means this APIDataSource is 574 # Only error if there is a request, which means this APIDataSource is
574 # actually being used to render a page. 575 # actually being used to render a page.
575 if request is not None: 576 if request is not None:
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 if self._disable_refs: 680 if self._disable_refs:
680 cache, ext = ( 681 cache, ext = (
681 (self._idl_cache_no_refs, '.idl') if (unix_name in idl_names) else 682 (self._idl_cache_no_refs, '.idl') if (unix_name in idl_names) else
682 (self._json_cache_no_refs, '.json')) 683 (self._json_cache_no_refs, '.json'))
683 else: 684 else:
684 cache, ext = ((self._idl_cache, '.idl') if (unix_name in idl_names) else 685 cache, ext = ((self._idl_cache, '.idl') if (unix_name in idl_names) else
685 (self._json_cache, '.json')) 686 (self._json_cache, '.json'))
686 return self._GenerateHandlebarContext( 687 return self._GenerateHandlebarContext(
687 cache.GetFromFile('%s/%s%s' % (self._base_path, unix_name, ext)), 688 cache.GetFromFile('%s/%s%s' % (self._base_path, unix_name, ext)),
688 path) 689 path)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698