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

Unified Diff: tools/json_schema_compiler/model.py

Issue 11079010: Extensions Docs Server: Preserve JSON declaration order in extensions documentation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tests! Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: tools/json_schema_compiler/model.py
diff --git a/tools/json_schema_compiler/model.py b/tools/json_schema_compiler/model.py
index a7aaac32dc2c1fef9674dbd8b10fd8766e417edd..79e1c766fbed4f7c9d1e0e990293a96d296c139a 100644
--- a/tools/json_schema_compiler/model.py
+++ b/tools/json_schema_compiler/model.py
@@ -6,6 +6,8 @@ import copy
import os.path
import re
+from json_parse import OrderedDict
+
class ParseException(Exception):
"""Thrown when data in the model is invalid.
"""
@@ -222,7 +224,7 @@ class Property(object):
self._unix_name = UnixName(self.name)
self._unix_name_used = False
self.optional = json.get('optional', False)
- self.functions = {}
+ self.functions = OrderedDict()
self.has_value = False
self.description = json.get('description')
self.parent = parent
@@ -408,7 +410,7 @@ def _GetModelHierarchy(entity):
def _AddTypes(model, json, namespace):
"""Adds Type objects to |model| contained in the 'types' field of |json|.
"""
- model.types = {}
+ model.types = OrderedDict()
for type_json in json.get('types', []):
type_ = Type(model, type_json['id'], type_json, namespace)
model.types[type_.name] = type_
@@ -417,7 +419,7 @@ def _AddFunctions(model, json, namespace):
"""Adds Function objects to |model| contained in the 'functions' field of
|json|.
"""
- model.functions = {}
+ model.functions = OrderedDict()
for function_json in json.get('functions', []):
function = Function(model, function_json, namespace, from_json=True)
model.functions[function.name] = function
@@ -425,7 +427,7 @@ def _AddFunctions(model, json, namespace):
def _AddEvents(model, json, namespace):
"""Adds Function objects to |model| contained in the 'events' field of |json|.
"""
- model.events = {}
+ model.events = OrderedDict()
for event_json in json.get('events', []):
event = Function(model, event_json, namespace, from_client=True)
model.events[event.name] = event
@@ -438,7 +440,7 @@ def _AddProperties(model,
"""Adds model.Property objects to |model| contained in the 'properties' field
of |json|.
"""
- model.properties = {}
+ model.properties = OrderedDict()
for name, property_json in json.get('properties', {}).items():
model.properties[name] = Property(
model,

Powered by Google App Engine
This is Rietveld 408576698