IfcPatch can now support patches that write to arbitrary files or have no output.

This commit is contained in:
Dion Moult
2023-06-16 13:22:33 +10:00
parent bac683e105
commit 47cc3158fd
+7 -2
View File
@@ -18,9 +18,9 @@
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with IfcPatch. If not, see <http://www.gnu.org/licenses/>. # along with IfcPatch. If not, see <http://www.gnu.org/licenses/>.
import os
import ifcopenshell import ifcopenshell
import logging import logging
import os
import typing import typing
import inspect import inspect
import collections import collections
@@ -95,7 +95,12 @@ def write(output, filepath):
:return: None :return: None
:rtype: None :rtype: None
""" """
if isinstance(output, str): if output is None:
return
elif isinstance(output, str):
if os.path.exists(output):
os.rename(output, filepath)
else:
with open(filepath, "w") as text_file: with open(filepath, "w") as text_file:
text_file.write(output) text_file.write(output)
else: else: