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

Unified Diff: tools/json_schema_compiler/schema_util.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/schema_util.py
diff --git a/tools/json_schema_compiler/schema_util.py b/tools/json_schema_compiler/schema_util.py
index 046e2bdb3367fd31bc7622bee42095ace773386f..b5f5c30906891e89078c42f3e0dec4c338dabb99 100644
--- a/tools/json_schema_compiler/schema_util.py
+++ b/tools/json_schema_compiler/schema_util.py
@@ -4,6 +4,8 @@
"""Utilies for the processing of schema python structures.
"""
+from json_parse import OrderedDict
+
def CapitalizeFirstLetter(value):
return value[0].capitalize() + value[1:]
@@ -22,7 +24,7 @@ def PrefixSchemasWithNamespace(schemas):
_PrefixWithNamespace(s.get("namespace"), s)
def _MaybePrefixFieldWithNamespace(namespace, schema, key):
- if type(schema) == dict and key in schema:
+ if isinstance(schema, (dict, OrderedDict)) and key in schema:
old_value = schema[key]
if not "." in old_value:
schema[key] = namespace + "." + old_value
@@ -33,7 +35,7 @@ def _PrefixTypesWithNamespace(namespace, types):
_MaybePrefixFieldWithNamespace(namespace, t, "customBindings")
def _PrefixWithNamespace(namespace, schema):
- if type(schema) == dict:
+ if isinstance(schema, (dict, OrderedDict)):
if "types" in schema:
_PrefixTypesWithNamespace(namespace, schema.get("types"))
_MaybePrefixFieldWithNamespace(namespace, schema, "$ref")
« tools/json_schema_compiler/ordered_dict.py ('K') | « tools/json_schema_compiler/ordered_dict_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698