Revert safe-browsing PrefixSet size_t handling.
[chromium-blink-merge.git] / tools / json_schema_compiler / schema_util.py
blobb8fb4044d098e199c1439bb39e8470382768ed46
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 """
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).
22 """
23 if '.' in ref:
24 return tuple(ref.rsplit('.', 1))
25 return (None, ref)
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."""
32 parts = []
33 full_name = namespace_name + "." + function_name
34 for part in full_name.split("."):
35 parts.append(CapitalizeFirstLetter(part))
36 if parts[0] == "Experimental":
37 del parts[0]
38 class_name = "".join(parts)
39 return class_name