(tree: Dict[Any, Any], cwd: str)
| 53 | # └── utils.cmake |
| 54 | # |
| 55 | def _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 | |
| 71 | class CMakeTestCase(unittest.TestCase): |
no test coverage detected