mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
typing
This commit is contained in:
@@ -24,11 +24,14 @@ import zipfile
|
||||
import functools
|
||||
import ifcopenshell
|
||||
from pathlib import Path
|
||||
from typing import Optional, Any, Union, Callable, Generator, Literal
|
||||
from typing import Optional, Any, Union, Callable, Generator, Literal, TYPE_CHECKING
|
||||
|
||||
from . import ifcopenshell_wrapper
|
||||
from .entity_instance import entity_instance
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import ifcopenshell.util.schema
|
||||
|
||||
|
||||
class Transaction:
|
||||
def __init__(self, ifc_file):
|
||||
@@ -406,7 +409,7 @@ class file:
|
||||
return e
|
||||
|
||||
@property
|
||||
def schema(self) -> Literal["IFC2X3", "IFC4", "IFC4X3"]:
|
||||
def schema(self) -> ifcopenshell.util.schema.IFC_SCHEMA:
|
||||
"""General IFC schema version: IFC2X3, IFC4, IFC4X3."""
|
||||
prefixes = ("IFC", "X", "_ADD", "_TC")
|
||||
reg = "".join(f"(?P<{s}>{s}\\d+)?" for s in prefixes)
|
||||
|
||||
@@ -60,7 +60,7 @@ IFC4x3_SPEC_URL_TEMPLATE = "https://ifc43-docs.standards.buildingsmart.org/IFC/R
|
||||
# child -> description
|
||||
# note: in IFC4x3 there is no children[] for properties
|
||||
|
||||
SUPPORTED_SCHEMA = Literal["IFC2X3", "IFC4", "IFC4X3"]
|
||||
SUPPORTED_SCHEMA = ifcopenshell.util.schema.IFC_SCHEMA
|
||||
SCHEMA_FILES: dict[SUPPORTED_SCHEMA, dict] = {
|
||||
"IFC2X3": {
|
||||
"entities": BASE_MODULE_PATH / "schema/ifc2x3_entities.json",
|
||||
|
||||
@@ -22,11 +22,12 @@ import time
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.attribute
|
||||
import ifcopenshell.ifcopenshell_wrapper as ifcopenshell_wrapper
|
||||
from typing import Union, Any
|
||||
from typing import Union, Any, Literal
|
||||
|
||||
# This is highly experimental and incomplete, however, it may work for simple datasets.
|
||||
|
||||
cwd = os.path.dirname(os.path.realpath(__file__))
|
||||
IFC_SCHEMA = Literal["IFC2X3", "IFC4", "IFC4X3"]
|
||||
|
||||
|
||||
def get_fallback_schema(version: str) -> str:
|
||||
|
||||
@@ -23,8 +23,8 @@ from typing import List
|
||||
|
||||
cwd = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
entity_to_type_map = {}
|
||||
type_to_entity_map = {}
|
||||
entity_to_type_map: dict[ifcopenshell.util.schema.IFC_SCHEMA, dict[str, list[str]]] = {}
|
||||
type_to_entity_map: dict[ifcopenshell.util.schema.IFC_SCHEMA, dict[str, list[str]]] = {}
|
||||
|
||||
mapped_schemas = {
|
||||
"IFC2X3": "entity_to_type_map_2x3.json",
|
||||
|
||||
Reference in New Issue
Block a user