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 c434dc167462a26a6e913a28e50d8b9bb79a4126..f74df8956e316aeccfcdb0bdef4d9f9a81e069bf 100644 |
--- a/tools/json_schema_compiler/schema_loader.py |
+++ b/tools/json_schema_compiler/schema_loader.py |
@@ -12,7 +12,8 @@ from model import Model |
class SchemaLoader(object): |
'''Resolves a type name into the namespace the type belongs to. |
''' |
- def __init__(self, api_path): |
+ def __init__(self, root, api_path): |
+ self._root = root |
self._api_path = api_path |
def ResolveType(self, full_name, default_namespace): |
@@ -25,7 +26,8 @@ class SchemaLoader(object): |
real_name = None |
for ext in ['json', 'idl']: |
filename = '%s.%s' % (namespace_name, ext) |
- if os.path.exists(filename): |
+ filepath = os.path.join(self._root, self._api_path, filename); |
+ if os.path.exists(filepath): |
real_name = filename |
break |
if real_name is None: |
@@ -37,12 +39,16 @@ class SchemaLoader(object): |
return namespace |
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 root and api_path arguments passed to the constructor.''' |
schema_filename, schema_extension = os.path.splitext(schema) |
+ schema_path = os.path.join(self._root, self._api_path, schema); |
not at google - send to devlin
2013/09/19 15:43:34
can the caller just make sure that the root is pro
msimonides
2013/09/20 11:32:01
This would be a problem with line 35-36: Model().A
not at google - send to devlin
2013/09/20 20:37:57
Ah. So there's a long-standing cleanup where we do
|
if schema_extension == '.json': |
- api_defs = json_schema.Load(schema) |
+ api_defs = json_schema.Load(schema_path) |
elif schema_extension == '.idl': |
- api_defs = idl_schema.Load(schema) |
+ api_defs = idl_schema.Load(schema_path) |
else: |
sys.exit('Did not recognize file extension %s for schema %s' % |
(schema_extension, schema)) |