Chromium Code Reviews| 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 e71be8ba33a9d3cea09f051087f172fced585527..3974bc5a3df4b074c29275def7f49285564635ad 100644 |
| --- a/tools/json_schema_compiler/schema_util.py |
| +++ b/tools/json_schema_compiler/schema_util.py |
| @@ -9,15 +9,19 @@ import json_parse |
| def CapitalizeFirstLetter(value): |
| return value[0].capitalize() + value[1:] |
| -def GetNamespace(ref_type): |
| - if '.' in ref_type: |
| - return ref_type[:ref_type.rindex('.')] |
| +def GetNamespace(ref): |
| + return SplitNamespace(ref)[0] |
| -def StripSchemaNamespace(s): |
| - last_dot = s.rfind('.') |
| - if not last_dot == -1: |
| - return s[last_dot + 1:] |
| - return s |
| +def StripNamespace(ref): |
| + return SplitNamespace(ref)[1] |
| + |
| +def SplitNamespace(ref): |
| + """Returns (namespace, thing) from |ref|. If |ref| isn't qualified then |
|
Yoyo Zhou
2013/01/26 01:43:02
Surely there's a better word than 'thing'.
not at google - send to devlin
2013/01/26 04:35:31
probably
|
| + returns (None, ref). |
| + """ |
| + if '.' in ref: |
| + return tuple(ref.rsplit('.', 1)) |
| + return (None, ref) |
| def JsFunctionNameToClassName(namespace_name, function_name): |
| """Transform a fully qualified function name like foo.bar.baz into FooBarBaz |