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

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

Issue 9617010: Move chrome.downloads out of experimental to dev (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 8 years, 6 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
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 from model import PropertyType
8
9 def IsLocalReference(prop, namespace):
10 return ((prop.type_ == PropertyType.REF) and
11 ((not '.' in prop.ref_type) or
12 prop.ref_type.startswith(namespace + '.')))
13
7 def StripSchemaNamespace(s): 14 def StripSchemaNamespace(s):
8 last_dot = s.rfind('.') 15 last_dot = s.rfind('.')
9 if not last_dot == -1: 16 if not last_dot == -1:
10 return s[last_dot + 1:] 17 return s[last_dot + 1:]
11 return s 18 return s
12 19
13 def PrefixSchemasWithNamespace(schemas): 20 def PrefixSchemasWithNamespace(schemas):
14 for s in schemas: 21 for s in schemas:
15 _PrefixWithNamespace(s.get("namespace"), s) 22 _PrefixWithNamespace(s.get("namespace"), s)
16 23
(...skipping 11 matching lines...) Expand all
28 def _PrefixWithNamespace(namespace, schema): 35 def _PrefixWithNamespace(namespace, schema):
29 if type(schema) == dict: 36 if type(schema) == dict:
30 if "types" in schema: 37 if "types" in schema:
31 _PrefixTypesWithNamespace(namespace, schema.get("types")) 38 _PrefixTypesWithNamespace(namespace, schema.get("types"))
32 _MaybePrefixFieldWithNamespace(namespace, schema, "$ref") 39 _MaybePrefixFieldWithNamespace(namespace, schema, "$ref")
33 for s in schema: 40 for s in schema:
34 _PrefixWithNamespace(namespace, schema[s]) 41 _PrefixWithNamespace(namespace, schema[s])
35 elif type(schema) == list: 42 elif type(schema) == list:
36 for s in schema: 43 for s in schema:
37 _PrefixWithNamespace(namespace, s) 44 _PrefixWithNamespace(namespace, s)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698