mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
Generalize shortened file.schema attribute
This commit is contained in:
@@ -358,7 +358,19 @@ class file(object):
|
|||||||
if attr[0:6] == "create":
|
if attr[0:6] == "create":
|
||||||
return functools.partial(self.create_entity, attr[6:])
|
return functools.partial(self.create_entity, attr[6:])
|
||||||
elif attr == "schema":
|
elif attr == "schema":
|
||||||
return {"IFC4X3_ADD1": "IFC4X3"}.get(self.wrapped_data.schema, self.wrapped_data.schema)
|
prefixes = ("IFC", "X", "_ADD", "_TC")
|
||||||
|
reg = "".join(f"(?P<{s}>{s}\d+)?" for s in prefixes)
|
||||||
|
match = re.match(reg, self.wrapped_data.schema)
|
||||||
|
version_tuple = tuple(
|
||||||
|
map(
|
||||||
|
lambda pp: int(pp[1][len(pp[0]):]) if pp[1] else None,
|
||||||
|
((p, match.group(p)) for p in prefixes),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return "".join(
|
||||||
|
"".join(map(str, t)) if t[1] else ""
|
||||||
|
for t in zip(prefixes, version_tuple[0:2])
|
||||||
|
)
|
||||||
elif attr == "schema_identifier":
|
elif attr == "schema_identifier":
|
||||||
return self.wrapped_data.schema
|
return self.wrapped_data.schema
|
||||||
elif attr == "schema_version":
|
elif attr == "schema_version":
|
||||||
|
|||||||
Reference in New Issue
Block a user