diff --git a/src/ifcopenshell-python/ifcopenshell/express/bootstrap.py b/src/ifcopenshell-python/ifcopenshell/express/bootstrap.py index 5a8e0e044a..8c0e7e00d7 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/bootstrap.py +++ b/src/ifcopenshell-python/ifcopenshell/express/bootstrap.py @@ -23,10 +23,7 @@ import itertools from pyparsing import * -try: - from functools import reduce -except: - pass +from functools import reduce class Expression: diff --git a/src/ifcopenshell-python/ifcopenshell/express/codegen.py b/src/ifcopenshell-python/ifcopenshell/express/codegen.py index dfcf5083c8..1d2b2b1262 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/codegen.py +++ b/src/ifcopenshell-python/ifcopenshell/express/codegen.py @@ -18,6 +18,7 @@ import itertools import functools +from pathlib import Path def indent(n, s): @@ -36,15 +37,4 @@ class Base: """ def emit(self): - import platform - - if tuple(map(int, platform.python_version_tuple())) < (2, 8): - from io import open as unicode_open - - unicode_type = unicode - else: - unicode_open = open - unicode_type = lambda x, *args, **kwargs: x - f = unicode_open(self.file_name, "w", encoding="utf-8") - f.write(unicode_type(repr(self), encoding="utf-8", errors="ignore")) - f.close() + Path(self.file_name).write_text(repr(self), encoding="utf-8") diff --git a/src/ifcopenshell-python/ifcopenshell/express/schema.py b/src/ifcopenshell-python/ifcopenshell/express/schema.py index 315db817b6..bd2e12d95f 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/schema.py +++ b/src/ifcopenshell-python/ifcopenshell/express/schema.py @@ -18,15 +18,9 @@ import nodes -import platform import collections import pyparsing -if tuple(map(int, platform.python_version_tuple())) < (2, 7): - import ordereddict - - collections.OrderedDict = ordereddict.OrderedDict - # According to ISO 10303-11 7.1.2: Letters: "... The case of # letters is significant only within explicit string literals."