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

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

Issue 9617010: Move chrome.downloads out of experimental to dev (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 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
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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 self.optional = json.get('optional', False) 183 self.optional = json.get('optional', False)
184 self.has_value = False 184 self.has_value = False
185 self.description = json.get('description') 185 self.description = json.get('description')
186 self.parent = parent 186 self.parent = parent
187 _AddProperties(self, json) 187 _AddProperties(self, json)
188 if is_additional_properties: 188 if is_additional_properties:
189 self.type_ = PropertyType.ADDITIONAL_PROPERTIES 189 self.type_ = PropertyType.ADDITIONAL_PROPERTIES
190 elif '$ref' in json: 190 elif '$ref' in json:
191 self.ref_type = json['$ref'] 191 self.ref_type = json['$ref']
192 self.type_ = PropertyType.REF 192 self.type_ = PropertyType.REF
193 elif 'enum' in json: 193 elif 'enum' in json and all(isinstance(value, basestring)
194 for value in json['enum']):
not at google - send to devlin 2012/06/12 18:34:38 Could you move the second check inside this block?
benjhayden 2012/06/12 20:15:42 Actually, I did this specifically so that it would
194 self.enum_values = [] 195 self.enum_values = []
195 for value in json['enum']: 196 for value in json['enum']:
196 self.enum_values.append(value) 197 self.enum_values.append(value)
197 self.type_ = PropertyType.ENUM 198 self.type_ = PropertyType.ENUM
198 elif 'type' in json: 199 elif 'type' in json:
199 json_type = json['type'] 200 json_type = json['type']
200 if json_type == 'string': 201 if json_type == 'string':
201 self.type_ = PropertyType.STRING 202 self.type_ = PropertyType.STRING
202 elif json_type == 'any': 203 elif json_type == 'any':
203 self.type_ = PropertyType.ANY 204 self.type_ = PropertyType.ANY
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 # handled in pure Javascript on the render process (and .: never reach 362 # handled in pure Javascript on the render process (and .: never reach
362 # C++ let alone the browser). 363 # C++ let alone the browser).
363 if property_json.get('type') == 'function': 364 if property_json.get('type') == 'function':
364 continue 365 continue
365 model.properties[name] = Property( 366 model.properties[name] = Property(
366 model, 367 model,
367 name, 368 name,
368 property_json, 369 property_json,
369 from_json=from_json, 370 from_json=from_json,
370 from_client=from_client) 371 from_client=from_client)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698