MCPcopy Create free account
hub / github.com/pytorch/executorch / _create_file_tree

Function _create_file_tree

tools/cmake/common/__init__.py:55–68  ·  view source on GitHub ↗
(tree: Dict[Any, Any], cwd: str)

Source from the content-addressed store, hash-verified

53# └── utils.cmake
54#
55def _create_file_tree(tree: Dict[Any, Any], cwd: str) -> None:
56 for name, value in tree.items():
57 if isinstance(value, str):
58 file_path = os.path.join(cwd, name)
59 assert not os.path.exists(file_path), f"file already exists: {file_path}"
60 os.makedirs(cwd, exist_ok=True)
61 with open(file_path, "w") as new_file:
62 new_file.write(value)
63 elif isinstance(value, dict):
64 new_cwd = os.path.join(cwd, name)
65 os.makedirs(new_cwd, exist_ok=True)
66 _create_file_tree(tree=value, cwd=new_cwd)
67 else:
68 raise AssertionError("invalid tree value", value)
69
70
71class CMakeTestCase(unittest.TestCase):

Callers 1

create_workspaceMethod · 0.85

Calls 2

itemsMethod · 0.80
writeMethod · 0.80

Tested by

no test coverage detected