Add a stream2_from_string() (mostly for wasm)

This commit is contained in:
Thomas Krijnen
2025-09-23 11:32:52 +02:00
parent b6abb24858
commit ab59173135
4 changed files with 54 additions and 2 deletions
@@ -301,10 +301,10 @@ def stream2(path: Union[Path, str]):
as a dictionary.
Args:
path (Union[Path, str]): _description_
path (Union[Path, str]): input file path
Yields:
_type_: _description_
dict: entity instance dictionaries
"""
streamer = ifcopenshell_wrapper.InstanceStreamer(str(path))
while streamer:
@@ -312,6 +312,22 @@ def stream2(path: Union[Path, str]):
yield inst
def stream2_from_string(data: str):
"""Streams the content of a file path from string, yielding each instance
as a dictionary.
Args:
data (str): input data
Yields:
dict: entity instance dictionaries
"""
streamer = ifcopenshell_wrapper.stream_from_string(data)
while streamer:
if inst := streamer.read_instance_py():
yield inst
def convert_path_to_rocksdb(ifcspf_path: Union[Path, str], rocksdb_path: Union[Path, str]):
"""Converts an IFC-SPF file on disk to the IfcOpenShell-specific
RocksDB encoding. RocksDB is an embedded key-value store that allows