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

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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 - |item_type| if this is an array, the type of items in the array 71 - |item_type| if this is an array, the type of items in the array
72 """ 72 """
73 def __init__(self, parent, name, json): 73 def __init__(self, parent, name, json):
74 if json.get('type') == 'array': 74 if json.get('type') == 'array':
75 self.type_ = PropertyType.ARRAY 75 self.type_ = PropertyType.ARRAY
76 self.item_type = Property(self, name + "Element", json['items'], 76 self.item_type = Property(self, name + "Element", json['items'],
77 from_json=True, 77 from_json=True,
78 from_client=True) 78 from_client=True)
79 elif json.get('type') == 'string': 79 elif json.get('type') == 'string':
80 self.type_ = PropertyType.STRING 80 self.type_ = PropertyType.STRING
81 elif json.get('type') == 'integer':
82 self.type_ = PropertyType.INTEGER
83 elif json.get('type') == 'double':
84 self.type_ = PropertyType.DOUBLE
85 elif json.get('type') == 'enum':
86 self.type_ = PropertyType.ENUM
81 else: 87 else:
82 if not ( 88 if not (
83 'properties' in json or 89 'properties' in json or
84 'additionalProperties' in json or 90 'additionalProperties' in json or
85 'functions' in json): 91 'functions' in json):
86 raise ParseException(self, name + " has no properties or functions") 92 raise ParseException(self, name + " has no properties or functions")
87 self.type_ = PropertyType.OBJECT 93 self.type_ = PropertyType.OBJECT
88 self.name = name 94 self.name = name
89 self.description = json.get('description') 95 self.description = json.get('description')
90 self.from_json = True 96 self.from_json = True
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 # handled in pure Javascript on the render process (and .: never reach 367 # handled in pure Javascript on the render process (and .: never reach
362 # C++ let alone the browser). 368 # C++ let alone the browser).
363 if property_json.get('type') == 'function': 369 if property_json.get('type') == 'function':
364 continue 370 continue
365 model.properties[name] = Property( 371 model.properties[name] = Property(
366 model, 372 model,
367 name, 373 name,
368 property_json, 374 property_json,
369 from_json=from_json, 375 from_json=from_json,
370 from_client=from_client) 376 from_client=from_client)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698