OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 copy import copy | 5 from copy import copy |
6 import logging | 6 import logging |
7 import posixpath | 7 import posixpath |
8 | 8 |
9 from api_models import GetNodeCategories | 9 from api_models import GetNodeCategories |
10 from api_schema_graph import APINodeCursor | 10 from api_schema_graph import APINodeCursor |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 def _FormatValue(value): | 56 def _FormatValue(value): |
57 '''Inserts commas every three digits for integer values. It is magic. | 57 '''Inserts commas every three digits for integer values. It is magic. |
58 ''' | 58 ''' |
59 s = str(value) | 59 s = str(value) |
60 return ','.join([s[max(0, i - 3):i] for i in range(len(s), 0, -3)][::-1]) | 60 return ','.join([s[max(0, i - 3):i] for i in range(len(s), 0, -3)][::-1]) |
61 | 61 |
62 | 62 |
63 class JSCView(object): | 63 class JSCView(object): |
64 '''Uses a Model from the JSON Schema Compiler and generates a dict that | 64 '''Uses a Model from the JSON Schema Compiler and generates a dict that |
65 a Handlebar template can use for a data source. | 65 a Motemplate template can use for a data source. |
66 ''' | 66 ''' |
67 | 67 |
68 def __init__(self, | 68 def __init__(self, |
69 content_script_apis, | 69 content_script_apis, |
70 jsc_model, | 70 jsc_model, |
71 availability_finder, | 71 availability_finder, |
72 json_cache, | 72 json_cache, |
73 template_cache, | 73 template_cache, |
74 features_bundle, | 74 features_bundle, |
75 event_byname_future, | 75 event_byname_future, |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 return misc_rows | 543 return misc_rows |
544 | 544 |
545 for category in table_info.iterkeys(): | 545 for category in table_info.iterkeys(): |
546 content = [] | 546 content = [] |
547 for node in table_info[category]: | 547 for node in table_info[category]: |
548 ext_type = PlatformToExtensionType(self._platform) | 548 ext_type = PlatformToExtensionType(self._platform) |
549 # Don't display nodes restricted to a different platform. | 549 # Don't display nodes restricted to a different platform. |
550 if ext_type not in node.get('extension_types', (ext_type,)): | 550 if ext_type not in node.get('extension_types', (ext_type,)): |
551 continue | 551 continue |
552 # If there is a 'partial' argument and it hasn't already been | 552 # If there is a 'partial' argument and it hasn't already been |
553 # converted to a Handlebar object, transform it to a template. | 553 # converted to a Motemplate object, transform it to a template. |
554 if 'partial' in node: | 554 if 'partial' in node: |
555 # Note: it's enough to copy() not deepcopy() because only a single | 555 # Note: it's enough to copy() not deepcopy() because only a single |
556 # top-level key is being modified. | 556 # top-level key is being modified. |
557 node = copy(node) | 557 node = copy(node) |
558 node['partial'] = self._template_cache.GetFromFile( | 558 node['partial'] = self._template_cache.GetFromFile( |
559 posixpath.join(PRIVATE_TEMPLATES, node['partial'])).Get() | 559 posixpath.join(PRIVATE_TEMPLATES, node['partial'])).Get() |
560 content.append(node) | 560 content.append(node) |
561 misc_rows.append({ 'title': category, 'content': content }) | 561 misc_rows.append({ 'title': category, 'content': content }) |
562 return misc_rows | 562 return misc_rows |
OLD | NEW |