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

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

Issue 10659021: Move chrome.appWindow to chrome.app.window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo 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
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 CapitalizeFirstLetter(value):
8 return value[0].capitalize() + value[1:]
9
7 def GetNamespace(ref_type): 10 def GetNamespace(ref_type):
8 if '.' in ref_type: 11 if '.' in ref_type:
9 return ref_type[:ref_type.rindex('.')] 12 return ref_type[:ref_type.rindex('.')]
10 13
11 def StripSchemaNamespace(s): 14 def StripSchemaNamespace(s):
12 last_dot = s.rfind('.') 15 last_dot = s.rfind('.')
13 if not last_dot == -1: 16 if not last_dot == -1:
14 return s[last_dot + 1:] 17 return s[last_dot + 1:]
15 return s 18 return s
16 19
(...skipping 15 matching lines...) Expand all
32 def _PrefixWithNamespace(namespace, schema): 35 def _PrefixWithNamespace(namespace, schema):
33 if type(schema) == dict: 36 if type(schema) == dict:
34 if "types" in schema: 37 if "types" in schema:
35 _PrefixTypesWithNamespace(namespace, schema.get("types")) 38 _PrefixTypesWithNamespace(namespace, schema.get("types"))
36 _MaybePrefixFieldWithNamespace(namespace, schema, "$ref") 39 _MaybePrefixFieldWithNamespace(namespace, schema, "$ref")
37 for s in schema: 40 for s in schema:
38 _PrefixWithNamespace(namespace, schema[s]) 41 _PrefixWithNamespace(namespace, schema[s])
39 elif type(schema) == list: 42 elif type(schema) == list:
40 for s in schema: 43 for s in schema:
41 _PrefixWithNamespace(namespace, s) 44 _PrefixWithNamespace(namespace, s)
45
46 def JsFunctionNameToClassName(namespace_name, function_name):
47 """Transform a fully qualified function name like foo.bar.baz into FooBarBaz
48
49 Also strips any leading 'Experimental' prefix."""
50 parts = []
51 full_name = namespace_name + "." + function_name
52 for part in full_name.split("."):
53 parts.append(CapitalizeFirstLetter(part))
54 if parts[0] == "Experimental":
55 del parts[0]
56 class_name = "".join(parts)
57 return class_name
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/schema_bundle_generator.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