From 20b1d981782a7d98c642b8d2e73ba071adaed60c Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 14 Jul 2026 13:00:32 +0500 Subject: [PATCH] downstream: express: drop Python 2 fallbacks --- .../ifcopenshell/express/bootstrap.py | 5 +---- .../ifcopenshell/express/codegen.py | 14 ++------------ .../ifcopenshell/express/schema.py | 7 +------ 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/express/bootstrap.py b/src/ifcopenshell-python/ifcopenshell/express/bootstrap.py index 8533f59ee5..f0095f83a5 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 fe997091b1..8e2cf2a956 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 ebb050d1ae..1f0a175d80 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/schema.py +++ b/src/ifcopenshell-python/ifcopenshell/express/schema.py @@ -18,14 +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." @@ -101,7 +96,7 @@ class Schema: for d in schema_declarations if d.rule == "RuleDeclaration" ] - + self.types = sort([(t.name, t) for t in declarations if isinstance(t, nodes.TypeDeclaration)]) self.entities = sort([(t.name, t) for t in declarations if isinstance(t, nodes.EntityDeclaration)]) self.rules = sort([(t.name, t) for t in declarations if isinstance(t, nodes.RuleDeclaration)])