mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 11:36:59 +00:00
Update reverse compilation to eliminate getattr() calls
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import ast
|
import ast
|
||||||
import collections
|
import collections
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
@@ -7,7 +8,24 @@ from codegen import indent
|
|||||||
|
|
||||||
|
|
||||||
def reverse_compile(s):
|
def reverse_compile(s):
|
||||||
return s.strip().replace("len(", "SIZEOF(").replace("assert ", "").replace(" is not False", "")
|
return re.sub(
|
||||||
|
"\s*\-\s*EXPRESS_ONE_BASED_INDEXING",
|
||||||
|
"",
|
||||||
|
re.sub(
|
||||||
|
", )?+.(, INDETERMINATE)\\"[::-1],
|
||||||
|
"]\\1[",
|
||||||
|
re.sub(
|
||||||
|
r", '(\w+)', INDETERMINATE\)",
|
||||||
|
".\\1",
|
||||||
|
s.strip()
|
||||||
|
.replace("len(", "SIZEOF(")
|
||||||
|
.replace("assert ", "")
|
||||||
|
.replace(" is not False", "")
|
||||||
|
.replace("getattr(", "")
|
||||||
|
.replace("express_getitem(", ""),
|
||||||
|
)[::-1],
|
||||||
|
)[::-1],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
Reference in New Issue
Block a user