mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
downstream: express: drop Python 2 fallbacks
This commit is contained in:
@@ -23,10 +23,7 @@ import itertools
|
||||
|
||||
from pyparsing import *
|
||||
|
||||
try:
|
||||
from functools import reduce
|
||||
except:
|
||||
pass
|
||||
from functools import reduce
|
||||
|
||||
|
||||
class Expression:
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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)])
|
||||
|
||||
Reference in New Issue
Block a user