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

Side by Side Diff: tools/json_schema_compiler/model.py

Issue 10797039: Extensions Docs Server: devtools API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move parsing logic into utils Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/extensions/docs/server2/templates/public/experimental_devtools_resources.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 os.path 6 import os.path
7 import re 7 import re
8 8
9 class ParseException(Exception): 9 class ParseException(Exception):
10 """Thrown when data in the model is invalid. 10 """Thrown when data in the model is invalid.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 self.type_ = PropertyType.ARRAY 78 self.type_ = PropertyType.ARRAY
79 self.item_type = Property(self, name + "Element", json['items'], 79 self.item_type = Property(self, name + "Element", json['items'],
80 from_json=True, 80 from_json=True,
81 from_client=True) 81 from_client=True)
82 elif json.get('type') == 'string': 82 elif json.get('type') == 'string':
83 self.type_ = PropertyType.STRING 83 self.type_ = PropertyType.STRING
84 else: 84 else:
85 if not ( 85 if not (
86 'properties' in json or 86 'properties' in json or
87 'additionalProperties' in json or 87 'additionalProperties' in json or
88 'functions' in json): 88 'functions' in json or
89 'events' in json):
89 raise ParseException(self, name + " has no properties or functions") 90 raise ParseException(self, name + " has no properties or functions")
90 self.type_ = PropertyType.OBJECT 91 self.type_ = PropertyType.OBJECT
91 self.name = name 92 self.name = name
92 self.description = json.get('description') 93 self.description = json.get('description')
93 self.from_json = True 94 self.from_json = True
94 self.from_client = True 95 self.from_client = True
95 self.parent = parent 96 self.parent = parent
96 self.instance_of = json.get('isInstanceOf', None) 97 self.instance_of = json.get('isInstanceOf', None)
97 _AddFunctions(self, json) 98 _AddFunctions(self, json)
98 _AddEvents(self, json) 99 _AddEvents(self, json)
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 of |json|. 353 of |json|.
353 """ 354 """
354 model.properties = {} 355 model.properties = {}
355 for name, property_json in json.get('properties', {}).items(): 356 for name, property_json in json.get('properties', {}).items():
356 model.properties[name] = Property( 357 model.properties[name] = Property(
357 model, 358 model,
358 name, 359 name,
359 property_json, 360 property_json,
360 from_json=from_json, 361 from_json=from_json,
361 from_client=from_client) 362 from_client=from_client)
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/templates/public/experimental_devtools_resources.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698