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

Unified Diff: tools/json_schema_compiler/schema_util.py

Issue 11953121: Fix up how the JSON Schema compiler decides whether to include or forward (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698