Write the output of an IFC patch to a file Typically a patch output would be a patched IFC model file object, or as a string. This function lets you agnostically write that output to a filepath. :param output: The results from ``ifcpatch.execute()`` / ``Patcher.get_output()`` :para
(output: Union[ifcopenshell.file, str, None], filepath: Union[Path, str])
| 128 | |
| 129 | |
| 130 | def write(output: Union[ifcopenshell.file, str, None], filepath: Union[Path, str]) -> None: |
| 131 | """Write the output of an IFC patch to a file |
| 132 | |
| 133 | Typically a patch output would be a patched IFC model file object, or as a |
| 134 | string. This function lets you agnostically write that output to a filepath. |
| 135 | |
| 136 | :param output: The results from ``ifcpatch.execute()`` / ``Patcher.get_output()`` |
| 137 | :param filepath: A filepath to where the results of the patched model should |
| 138 | be written to. |
| 139 | :return: None |
| 140 | """ |
| 141 | if output is None: |
| 142 | return |
| 143 | elif isinstance(output, str): |
| 144 | if os.path.exists(output): |
| 145 | shutil.move(output, filepath) |
| 146 | else: |
| 147 | with open(filepath, "w") as text_file: |
| 148 | text_file.write(output) |
| 149 | else: |
| 150 | output.write(filepath) |
| 151 | |
| 152 | |
| 153 | def extract_docs( |