9 raise RuntimeError(
'Got invalid filename (empty string).')
13 full_path = os.path.join(path, rel)
14 if full_path[-1] ==
'/':
15 raise RuntimeError(
'Attempted to import a directory')
17 if not os.path.isfile(full_path):
18 return full_path,
None 19 with open(full_path)
as f:
20 return full_path, f.read()
23 paths = [path] + os.environ.get(
"WIRECELL_PATH",
"").split(
":")
24 paths += os.environ.get(
"JSONNET_PATH",
"").split(
":")
29 full_path, content =
try_path(maybe, rel)
33 return full_path, content
34 raise RuntimeError(
'File not found')
39 Load and evaluate a jsonnet file returning data structure. 41 text = _jsonnet.evaluate_file(fname, import_callback=import_callback)
42 return json.loads(text)
def import_callback(path, rel)