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

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

Issue 10367002: Make all extension api types fully qualified. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix webrequest tests Created 8 years, 7 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
(Empty)
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
3 # found in the LICENSE file.
4 """Utilies for the processing of schema python structures.
5 """
6
7 def StripSchemaNamespace(s):
8 last_dot = s.rfind('.')
9 if not last_dot == -1:
10 return s[last_dot + 1:]
11 return s
12
13 def PrefixSchemasWithNamespace(schemas):
14 for s in schemas:
15 _PrefixWithNamespace(s.get("namespace"), s)
16
17 def _MaybePrefixFieldWithNamespace(namespace, schema, key):
18 if type(schema) == dict and key in schema:
19 old_value = schema[key]
20 if not "." in old_value:
21 schema[key] = namespace + "." + old_value
22
23 def _PrefixTypesWithNamespace(namespace, types):
24 for t in types:
25 _MaybePrefixFieldWithNamespace(namespace, t, "id")
26 _MaybePrefixFieldWithNamespace(namespace, t, "customBindings")
27
28 def _PrefixWithNamespace(namespace, schema):
29 if type(schema) == dict:
30 if "types" in schema:
31 _PrefixTypesWithNamespace(namespace, schema.get("types"))
32 _MaybePrefixFieldWithNamespace(namespace, schema, "$ref")
33 for s in schema:
34 _PrefixWithNamespace(namespace, schema[s])
35 elif type(schema) == list:
36 for s in schema:
37 _PrefixWithNamespace(namespace, s)
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/model_test.py ('k') | tools/json_schema_compiler/schema_util_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698