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.
7 def CapitalizeFirstLetter(value
):
8 return value
[0].capitalize() + value
[1:]
11 def GetNamespace(ref
):
12 return SplitNamespace(ref
)[0]
15 def StripNamespace(ref
):
16 return SplitNamespace(ref
)[1]
19 def SplitNamespace(ref
):
20 """Returns (namespace, entity) from |ref|, e.g. app.window.AppWindow ->
21 (app.window, AppWindow). If |ref| isn't qualified then returns (None, ref).
24 return tuple(ref
.rsplit('.', 1))
28 def JsFunctionNameToClassName(namespace_name
, function_name
):
29 """Transform a fully qualified function name like foo.bar.baz into FooBarBaz
31 Also strips any leading 'Experimental' prefix."""
33 full_name
= namespace_name
+ "." + function_name
34 for part
in full_name
.split("."):
35 parts
.append(CapitalizeFirstLetter(part
))
36 if parts
[0] == "Experimental":
38 class_name
= "".join(parts
)