MCPcopy Create free account
hub / github.com/Walter0807/MotionBERT / construct_include

Function construct_include

lib/utils/tools.py:32–44  ·  view source on GitHub ↗

Include file referenced at node.

(loader: Loader, node: yaml.Node)

Source from the content-addressed store, hash-verified

30 super().__init__(stream)
31
32def construct_include(loader: Loader, node: yaml.Node) -> Any:
33 """Include file referenced at node."""
34
35 filename = os.path.abspath(os.path.join(loader._root, loader.construct_scalar(node)))
36 extension = os.path.splitext(filename)[1].lstrip('.')
37
38 with open(filename, 'r') as f:
39 if extension in ('yaml', 'yml'):
40 return yaml.load(f, Loader)
41 elif extension in ('json', ):
42 return json.load(f)
43 else:
44 return ''.join(f.readlines())
45
46def get_config(config_path):
47 yaml.add_constructor('!include', construct_include, Loader)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected