diff --git a/src/ifcopenshell-python/ifcopenshell/__init__.py b/src/ifcopenshell-python/ifcopenshell/__init__.py index 4dd11c1ed6..cb1b7b8aba 100644 --- a/src/ifcopenshell-python/ifcopenshell/__init__.py +++ b/src/ifcopenshell-python/ifcopenshell/__init__.py @@ -379,12 +379,12 @@ def stream2(path: Union[Path, str], mmap: bool = False, page_size: int = 0): import builtins f = builtins.open(path, encoding="ascii") - strm = ifcopenshell_wrapper.InstanceStreamer() - strm.pushPage(f.read(page_size)) + strm = ifcopenshell_wrapper.instance_streamer() + strm.push_page(f.read(page_size)) finished = False while True: - while strm.hasSemicolon(): - if inst := strm.readInstancePy(): + while strm.has_semicolon(): + if inst := strm.read_instance_py(): yield inst else: finished = True @@ -393,13 +393,13 @@ def stream2(path: Union[Path, str], mmap: bool = False, page_size: int = 0): break else: if data := f.read(page_size): - strm.pushPage(data) + strm.push_page(data) else: break else: - streamer = ifcopenshell_wrapper.InstanceStreamer(str(path), mmap) + streamer = ifcopenshell_wrapper.instance_streamer(str(path), mmap) while streamer: - if inst := streamer.readInstancePy(): + if inst := streamer.read_instance_py(): yield inst diff --git a/src/ifcopenshell-python/ifcopenshell/geom/stats.py b/src/ifcopenshell-python/ifcopenshell/geom/stats.py index 9266d532d4..536c55c1e7 100644 --- a/src/ifcopenshell-python/ifcopenshell/geom/stats.py +++ b/src/ifcopenshell-python/ifcopenshell/geom/stats.py @@ -129,7 +129,7 @@ class BooleanResultCounter: class StatsCollector: - streamer: ifcopenshell_wrapper.InstanceStreamer + streamer: ifcopenshell_wrapper.instance_streamer page_size: Optional[int] file_stream: Optional[IO[str]] @@ -141,7 +141,7 @@ class StatsCollector: num_semis: int = 0 def __init__(self): - self.streamer = ifcopenshell_wrapper.InstanceStreamer() + self.streamer = ifcopenshell_wrapper.instance_streamer() self.needs_data = True self.counters = [ProductCounter(), BooleanResultCounter()] @@ -151,9 +151,9 @@ class StatsCollector: self.feed(self.file_stream.read(self.page_size)) def feed(self, data: str): - self.streamer.pushPage(data) + self.streamer.push_page(data) self.needs_data = False - self.num_semis = self.streamer.semicolonCount() + self.num_semis = self.streamer.semicolon_count() @staticmethod def fromFilePath(fn, page_size: int = 102400): @@ -164,7 +164,7 @@ class StatsCollector: def next(self): if self.num_semis > 0: - if inst := self.streamer.readInstancePy(True): + if inst := self.streamer.read_instance_py(True): self.num_semis -= 1 return inst["type"], dict(list(inst.items())[2:]) else: diff --git a/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi b/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi index c7ae9cf50d..d7603c3c00 100644 --- a/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi +++ b/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi @@ -298,18 +298,21 @@ class IfcLateBoundEntity(IfcBaseEntity): def __init__(self, decl, data): ... def declaration(self): ... -class InstanceStreamer: +class instance_streamer: def __init__(self, *args): ... - def bypassTypes(self, type_names): ... + def bypass_types(self, type_names): ... def bypassed_instances(self): ... coerce_attribute_count: bool - def hasSemicolon(self): ... + def has_semicolon(self): ... + def header(self): ... def inverses(self, *args): ... - def pushPage(self, page): ... - def readInstancePy(self, type_as_declaration_instance=False): ... + def push_page(self, page_data): ... + def read_instance_py(self, type_as_declaration_instance=False): ... def references(self, *args): ... - def semicolonCount(self): ... + def schema(self): ... + def semicolon_count(self): ... def status(self): ... + def yield_header_instances(self, enabled): ... class Iterator: def __init__(self, *args): ... diff --git a/src/ifcwrap/IfcParseWrapper.i b/src/ifcwrap/IfcParseWrapper.i index c915bf6ca0..ec76973e4d 100644 --- a/src/ifcwrap/IfcParseWrapper.i +++ b/src/ifcwrap/IfcParseWrapper.i @@ -1306,7 +1306,7 @@ from .entity_instance import entity_instance_mixin as _entity_instance_mixin_bas %} %extend ifcopenshell::instance_streamer> { - PyObject* readInstancePy(bool type_as_declaration_instance=false) { + PyObject* read_instance_py(bool type_as_declaration_instance=false) { auto simply_type_to_dictionary = [&](const express::Base& t) -> PyObject* { const auto& nm = t.declaration().name(); auto ifc_val = t.get_attribute_value(0);