MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / write

Function write

src/ifcpatch/ifcpatch/__init__.py:130–150  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

128
129
130def 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
153def extract_docs(

Callers 5

__init__Method · 0.50
__init__Method · 0.50
__init__Method · 0.50
__init__Method · 0.50

Calls 3

moveMethod · 0.80
openFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected