This commit is contained in:
Andrej730
2024-09-24 10:44:10 +05:00
parent 7045fba9c0
commit 4e3d6f1773
4 changed files with 49 additions and 27 deletions
@@ -59,7 +59,7 @@ import sys
import zipfile
import tempfile
from pathlib import Path
from typing import Optional, Union, TYPE_CHECKING, Any
from typing import Optional, Union, TYPE_CHECKING, Any, overload, Literal
if TYPE_CHECKING:
import ifcopenshell.express.schema_class
@@ -119,9 +119,24 @@ class SchemaError(Error):
pass
def open(path: Union[os.PathLike, str], format: Optional[str] = None, should_stream: bool = False) -> file:
@overload
def open(
path: Union[os.PathLike, str], format: Optional[str] = None, *, should_stream: Literal[False] = False
) -> Union[file, sqlite]: ...
@overload
def open(path: Union[os.PathLike, str], format: Optional[str] = None, *, should_stream: Literal[True]) -> stream: ...
@overload
def open(
path: Union[os.PathLike, str], format: Optional[str] = None, *, should_stream: bool
) -> Union[file, sqlite, stream]: ...
def open(
path: Union[os.PathLike, str], format: Optional[str] = None, should_stream: bool = False
) -> Union[file, sqlite, stream]:
"""Loads an IFC dataset from a filepath
:param should_stream: Whether to open the file in streaming mode. Could be useful
for reading large files.
You can specify a file format. If no format is given, it is guessed from
its extension. Currently supported specified format: .ifc | .ifcZIP |
.ifcXML.