Index: tools/json_schema_compiler/schema_util.py |
diff --git a/tools/json_schema_compiler/schema_util.py b/tools/json_schema_compiler/schema_util.py |
index 177e77f9b1ba5ec847f559df1546daa10a17465f..046e2bdb3367fd31bc7622bee42095ace773386f 100644 |
--- a/tools/json_schema_compiler/schema_util.py |
+++ b/tools/json_schema_compiler/schema_util.py |
@@ -4,6 +4,9 @@ |
"""Utilies for the processing of schema python structures. |
""" |
+def CapitalizeFirstLetter(value): |
+ return value[0].capitalize() + value[1:] |
+ |
def GetNamespace(ref_type): |
if '.' in ref_type: |
return ref_type[:ref_type.rindex('.')] |
@@ -39,3 +42,16 @@ def _PrefixWithNamespace(namespace, schema): |
elif type(schema) == list: |
for s in schema: |
_PrefixWithNamespace(namespace, s) |
+ |
+def JsFunctionNameToClassName(namespace_name, function_name): |
+ """Transform a fully qualified function name like foo.bar.baz into FooBarBaz |
+ |
+ Also strips any leading 'Experimental' prefix.""" |
+ parts = [] |
+ full_name = namespace_name + "." + function_name |
+ for part in full_name.split("."): |
+ parts.append(CapitalizeFirstLetter(part)) |
+ if parts[0] == "Experimental": |
+ del parts[0] |
+ class_name = "".join(parts) |
+ return class_name |