| OLD | NEW |
| 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 json | 6 import json |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 from collections import defaultdict, Mapping | 9 from collections import defaultdict, Mapping |
| 10 | 10 |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 self._add_rules_schema = None | 580 self._add_rules_schema = None |
| 581 | 581 |
| 582 def SetSamplesDataSourceFactory(self, samples_data_source_factory): | 582 def SetSamplesDataSourceFactory(self, samples_data_source_factory): |
| 583 self._samples_data_source_factory = samples_data_source_factory | 583 self._samples_data_source_factory = samples_data_source_factory |
| 584 | 584 |
| 585 def SetReferenceResolverFactory(self, ref_resolver_factory): | 585 def SetReferenceResolverFactory(self, ref_resolver_factory): |
| 586 self._ref_resolver_factory = ref_resolver_factory | 586 self._ref_resolver_factory = ref_resolver_factory |
| 587 | 587 |
| 588 def SetTemplateDataSource(self, template_data_source_factory): | 588 def SetTemplateDataSource(self, template_data_source_factory): |
| 589 # This TemplateDataSource is only being used for fetching template data. | 589 # This TemplateDataSource is only being used for fetching template data. |
| 590 self._template_data_source = template_data_source_factory.Create(None, '') | 590 self._template_data_source = template_data_source_factory.Create( |
| 591 None, {}) |
| 591 | 592 |
| 592 def Create(self, request, disable_refs=False): | 593 def Create(self, request, disable_refs=False): |
| 593 '''Create an APIDataSource. |disable_refs| specifies whether $ref's in | 594 '''Create an APIDataSource. |disable_refs| specifies whether $ref's in |
| 594 APIs being processed by the |ToDict| method of _JSCModel follows $ref's | 595 APIs being processed by the |ToDict| method of _JSCModel follows $ref's |
| 595 in the API. This prevents endless recursion in ReferenceResolver. | 596 in the API. This prevents endless recursion in ReferenceResolver. |
| 596 ''' | 597 ''' |
| 597 if self._samples_data_source_factory is None: | 598 if self._samples_data_source_factory is None: |
| 598 # Only error if there is a request, which means this APIDataSource is | 599 # Only error if there is a request, which means this APIDataSource is |
| 599 # actually being used to render a page. | 600 # actually being used to render a page. |
| 600 if request is not None: | 601 if request is not None: |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 if self._disable_refs: | 707 if self._disable_refs: |
| 707 cache, ext = ( | 708 cache, ext = ( |
| 708 (self._idl_cache_no_refs, '.idl') if (unix_name in idl_names) else | 709 (self._idl_cache_no_refs, '.idl') if (unix_name in idl_names) else |
| 709 (self._json_cache_no_refs, '.json')) | 710 (self._json_cache_no_refs, '.json')) |
| 710 else: | 711 else: |
| 711 cache, ext = ((self._idl_cache, '.idl') if (unix_name in idl_names) else | 712 cache, ext = ((self._idl_cache, '.idl') if (unix_name in idl_names) else |
| 712 (self._json_cache, '.json')) | 713 (self._json_cache, '.json')) |
| 713 return self._GenerateHandlebarContext( | 714 return self._GenerateHandlebarContext( |
| 714 cache.GetFromFile('%s/%s%s' % (self._base_path, unix_name, ext)), | 715 cache.GetFromFile('%s/%s%s' % (self._base_path, unix_name, ext)), |
| 715 path) | 716 path) |
| OLD | NEW |