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

Unified Diff: tools/json_schema_compiler/schema_loader.py

Issue 515983003: Fixing json compiler preview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing unneeded code. Created 6 years, 4 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_loader.py
diff --git a/tools/json_schema_compiler/schema_loader.py b/tools/json_schema_compiler/schema_loader.py
index a42f4c4c5673fd1f2c09d6a45356f1a32f53d2c3..3054560eb25ad1c84425ea39a512a9798f50315a 100644
--- a/tools/json_schema_compiler/schema_loader.py
+++ b/tools/json_schema_compiler/schema_loader.py
@@ -50,13 +50,7 @@ class SchemaLoader(object):
self._include_rules = [(real_path, cpp_namespace_pattern)]
self._include_rules.extend(include_rules)
- def ResolveType(self, full_name, default_namespace):
- name_parts = full_name.rsplit('.', 1)
- if len(name_parts) == 1:
- if full_name not in default_namespace.types:
- return None
- return default_namespace
- full_namespace, type_name = full_name.rsplit('.', 1)
+ def ResolveNamespace(self, full_namespace):
filenames = GenerateFilenames(full_namespace)
for path, namespace in self._include_rules:
for filename in reversed(filenames):
@@ -66,21 +60,30 @@ class SchemaLoader(object):
self.LoadSchema(filepath)[0],
os.path.join(self._display_path, filepath),
environment=CppNamespaceEnvironment(namespace))
- if type_name in namespace.types:
- return namespace
+ return namespace
not at google - send to devlin 2014/08/28 19:41:35 (I know the code is already like this but...) |nam
lfg 2014/08/28 23:14:59 Done.
+ return None
+
+ def ResolveType(self, full_name, default_namespace):
+ name_parts = full_name.rsplit('.', 1)
+ if len(name_parts) == 1:
+ if full_name not in default_namespace.types:
+ return None
+ return default_namespace
+ full_namespace, type_name = full_name.rsplit('.', 1)
+ namespace = self.ResolveNamespace(full_namespace)
+ if namespace and type_name in namespace.types:
+ return namespace
return None
def LoadSchema(self, schema):
'''Load a schema definition. The schema parameter must be a file name
- without any path component - the file is loaded from the path defined by
- the real_path argument passed to the constructor.'''
+ with the full path.'''
schema_filename, schema_extension = os.path.splitext(schema)
- schema_path = os.path.join(self._real_path, schema);
if schema_extension == '.json':
- api_defs = json_schema.Load(schema_path)
+ api_defs = json_schema.Load(schema)
elif schema_extension == '.idl':
- api_defs = idl_schema.Load(schema_path)
+ api_defs = idl_schema.Load(schema)
else:
sys.exit('Did not recognize file extension %s for schema %s' %
(schema_extension, schema))
« tools/json_schema_compiler/preview.py ('K') | « tools/json_schema_compiler/preview.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698