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 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 def Copy(self): | 292 def Copy(self): |
293 """Makes a copy of this model.Property object and allow the unix_name to be | 293 """Makes a copy of this model.Property object and allow the unix_name to be |
294 set again. | 294 set again. |
295 """ | 295 """ |
296 property_copy = copy.copy(self) | 296 property_copy = copy.copy(self) |
297 property_copy._unix_name_used = False | 297 property_copy._unix_name_used = False |
298 return property_copy | 298 return property_copy |
299 | 299 |
300 unix_name = property(GetUnixName, SetUnixName) | 300 unix_name = property(GetUnixName, SetUnixName) |
301 | 301 |
302 class _Info(object): | |
303 def __init__(self, is_fundamental, name): | |
304 self.is_fundamental = is_fundamental | |
305 self.name = name | |
306 | |
307 def __repr__(self): | |
308 return self.name | |
not at google - send to devlin
2012/08/20 05:27:10
Add a note that this is so it can be pickled.
Als
cduvall
2012/08/20 21:28:09
Done.
| |
309 | |
302 class PropertyType(object): | 310 class PropertyType(object): |
303 """Enum of different types of properties/parameters. | 311 """Enum of different types of properties/parameters. |
304 """ | 312 """ |
305 class _Info(object): | |
306 def __init__(self, is_fundamental, name): | |
307 self.is_fundamental = is_fundamental | |
308 self.name = name | |
309 | |
310 def __repr__(self): | |
311 return self.name | |
312 | |
313 INTEGER = _Info(True, "INTEGER") | 313 INTEGER = _Info(True, "INTEGER") |
314 INT64 = _Info(True, "INT64") | 314 INT64 = _Info(True, "INT64") |
315 DOUBLE = _Info(True, "DOUBLE") | 315 DOUBLE = _Info(True, "DOUBLE") |
316 BOOLEAN = _Info(True, "BOOLEAN") | 316 BOOLEAN = _Info(True, "BOOLEAN") |
317 STRING = _Info(True, "STRING") | 317 STRING = _Info(True, "STRING") |
318 ENUM = _Info(False, "ENUM") | 318 ENUM = _Info(False, "ENUM") |
319 ARRAY = _Info(False, "ARRAY") | 319 ARRAY = _Info(False, "ARRAY") |
320 REF = _Info(False, "REF") | 320 REF = _Info(False, "REF") |
321 CHOICES = _Info(False, "CHOICES") | 321 CHOICES = _Info(False, "CHOICES") |
322 OBJECT = _Info(False, "OBJECT") | 322 OBJECT = _Info(False, "OBJECT") |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
377 of |json|. | 377 of |json|. |
378 """ | 378 """ |
379 model.properties = {} | 379 model.properties = {} |
380 for name, property_json in json.get('properties', {}).items(): | 380 for name, property_json in json.get('properties', {}).items(): |
381 model.properties[name] = Property( | 381 model.properties[name] = Property( |
382 model, | 382 model, |
383 name, | 383 name, |
384 property_json, | 384 property_json, |
385 from_json=from_json, | 385 from_json=from_json, |
386 from_client=from_client) | 386 from_client=from_client) |
OLD | NEW |