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

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

Issue 10639020: Switch the downloads API over to IDL/json_schema_compiler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years, 5 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
« no previous file with comments | « tools/json_schema_compiler/model.py ('k') | tools/json_schema_compiler/test/idl_basics.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 """Utilies for the processing of schema python structures. 4 """Utilies for the processing of schema python structures.
5 """ 5 """
6 6
7 def GetNamespace(ref_type):
8 if '.' in ref_type:
9 return ref_type[:ref_type.rindex('.')]
10
7 def StripSchemaNamespace(s): 11 def StripSchemaNamespace(s):
8 last_dot = s.rfind('.') 12 last_dot = s.rfind('.')
9 if not last_dot == -1: 13 if not last_dot == -1:
10 return s[last_dot + 1:] 14 return s[last_dot + 1:]
11 return s 15 return s
12 16
13 def PrefixSchemasWithNamespace(schemas): 17 def PrefixSchemasWithNamespace(schemas):
14 for s in schemas: 18 for s in schemas:
15 _PrefixWithNamespace(s.get("namespace"), s) 19 _PrefixWithNamespace(s.get("namespace"), s)
16 20
(...skipping 11 matching lines...) Expand all
28 def _PrefixWithNamespace(namespace, schema): 32 def _PrefixWithNamespace(namespace, schema):
29 if type(schema) == dict: 33 if type(schema) == dict:
30 if "types" in schema: 34 if "types" in schema:
31 _PrefixTypesWithNamespace(namespace, schema.get("types")) 35 _PrefixTypesWithNamespace(namespace, schema.get("types"))
32 _MaybePrefixFieldWithNamespace(namespace, schema, "$ref") 36 _MaybePrefixFieldWithNamespace(namespace, schema, "$ref")
33 for s in schema: 37 for s in schema:
34 _PrefixWithNamespace(namespace, schema[s]) 38 _PrefixWithNamespace(namespace, schema[s])
35 elif type(schema) == list: 39 elif type(schema) == list:
36 for s in schema: 40 for s in schema:
37 _PrefixWithNamespace(namespace, s) 41 _PrefixWithNamespace(namespace, s)
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/model.py ('k') | tools/json_schema_compiler/test/idl_basics.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698