Skip to content

Commit

Permalink
util.doc - use release schema version for IFC4X3
Browse files Browse the repository at this point in the history
As it will be more like to be available in the ifcopenshell package. Related to #4565
  • Loading branch information
Andrej730 committed Apr 22, 2024
1 parent 889c9a9 commit 34a4e3f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/ifcopenshell-python/ifcopenshell/util/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
from pathlib import Path
import copy
import ifcopenshell
import ifcopenshell.ifcopenshell_wrapper as ifcopenshell_wrapper
import ifcopenshell.util.attribute
import ifcopenshell.util.schema
from typing import Optional, Literal

try:
import glob
Expand Down Expand Up @@ -58,8 +60,8 @@
# child -> description
# note: in IFC4x3 there is no children[] for properties


SCHEMA_FILES = {
SUPPORTED_SCHEMA = Literal["IFC2X3", "IFC4", "IFC4X3"]
SCHEMA_FILES: dict[SUPPORTED_SCHEMA, dict] = {
"IFC2X3": {
"entities": BASE_MODULE_PATH / "schema/ifc2x3_entities.json",
"properties": BASE_MODULE_PATH / "schema/ifc2x3_properties.json",
Expand All @@ -81,7 +83,11 @@
}

db = None
schema_by_name = {"IFC2X3": None, "IFC4": None, "IFC4X3": None}
schema_by_name: dict[SUPPORTED_SCHEMA, Optional[ifcopenshell_wrapper.schema_definition]] = {
"IFC2X3": None,
"IFC4": None,
"IFC4X3": None,
}


def get_db(version):
Expand All @@ -103,11 +109,12 @@ def get_db(version):
return db.get(version)


def get_schema_by_name(version: str):
def get_schema_by_name(version: str) -> ifcopenshell_wrapper.schema_definition:
global schema_by_name
version = ifcopenshell.util.schema.get_fallback_schema(version)
if not schema_by_name[version]:
schema_by_name[version] = ifcopenshell.ifcopenshell_wrapper.schema_by_name(version)
schema_name = "IFC4X3_ADD2" if version == "IFC4X3" else version
schema_by_name[version] = ifcopenshell_wrapper.schema_by_name(schema_name)
return schema_by_name[version]


Expand Down

0 comments on commit 34a4e3f

Please sign in to comment.