instance_streamer: migrate to snake case

This commit is contained in:
Andrej730
2026-07-22 16:49:01 +05:00
parent e98a3a5c2c
commit 298e4cfd8d
4 changed files with 22 additions and 19 deletions
@@ -379,12 +379,12 @@ def stream2(path: Union[Path, str], mmap: bool = False, page_size: int = 0):
import builtins import builtins
f = builtins.open(path, encoding="ascii") f = builtins.open(path, encoding="ascii")
strm = ifcopenshell_wrapper.InstanceStreamer() strm = ifcopenshell_wrapper.instance_streamer()
strm.pushPage(f.read(page_size)) strm.push_page(f.read(page_size))
finished = False finished = False
while True: while True:
while strm.hasSemicolon(): while strm.has_semicolon():
if inst := strm.readInstancePy(): if inst := strm.read_instance_py():
yield inst yield inst
else: else:
finished = True finished = True
@@ -393,13 +393,13 @@ def stream2(path: Union[Path, str], mmap: bool = False, page_size: int = 0):
break break
else: else:
if data := f.read(page_size): if data := f.read(page_size):
strm.pushPage(data) strm.push_page(data)
else: else:
break break
else: else:
streamer = ifcopenshell_wrapper.InstanceStreamer(str(path), mmap) streamer = ifcopenshell_wrapper.instance_streamer(str(path), mmap)
while streamer: while streamer:
if inst := streamer.readInstancePy(): if inst := streamer.read_instance_py():
yield inst yield inst
@@ -129,7 +129,7 @@ class BooleanResultCounter:
class StatsCollector: class StatsCollector:
streamer: ifcopenshell_wrapper.InstanceStreamer streamer: ifcopenshell_wrapper.instance_streamer
page_size: Optional[int] page_size: Optional[int]
file_stream: Optional[IO[str]] file_stream: Optional[IO[str]]
@@ -141,7 +141,7 @@ class StatsCollector:
num_semis: int = 0 num_semis: int = 0
def __init__(self): def __init__(self):
self.streamer = ifcopenshell_wrapper.InstanceStreamer() self.streamer = ifcopenshell_wrapper.instance_streamer()
self.needs_data = True self.needs_data = True
self.counters = [ProductCounter(), BooleanResultCounter()] self.counters = [ProductCounter(), BooleanResultCounter()]
@@ -151,9 +151,9 @@ class StatsCollector:
self.feed(self.file_stream.read(self.page_size)) self.feed(self.file_stream.read(self.page_size))
def feed(self, data: str): def feed(self, data: str):
self.streamer.pushPage(data) self.streamer.push_page(data)
self.needs_data = False self.needs_data = False
self.num_semis = self.streamer.semicolonCount() self.num_semis = self.streamer.semicolon_count()
@staticmethod @staticmethod
def fromFilePath(fn, page_size: int = 102400): def fromFilePath(fn, page_size: int = 102400):
@@ -164,7 +164,7 @@ class StatsCollector:
def next(self): def next(self):
if self.num_semis > 0: if self.num_semis > 0:
if inst := self.streamer.readInstancePy(True): if inst := self.streamer.read_instance_py(True):
self.num_semis -= 1 self.num_semis -= 1
return inst["type"], dict(list(inst.items())[2:]) return inst["type"], dict(list(inst.items())[2:])
else: else:
@@ -298,18 +298,21 @@ class IfcLateBoundEntity(IfcBaseEntity):
def __init__(self, decl, data): ... def __init__(self, decl, data): ...
def declaration(self): ... def declaration(self): ...
class InstanceStreamer: class instance_streamer:
def __init__(self, *args): ... def __init__(self, *args): ...
def bypassTypes(self, type_names): ... def bypass_types(self, type_names): ...
def bypassed_instances(self): ... def bypassed_instances(self): ...
coerce_attribute_count: bool coerce_attribute_count: bool
def hasSemicolon(self): ... def has_semicolon(self): ...
def header(self): ...
def inverses(self, *args): ... def inverses(self, *args): ...
def pushPage(self, page): ... def push_page(self, page_data): ...
def readInstancePy(self, type_as_declaration_instance=False): ... def read_instance_py(self, type_as_declaration_instance=False): ...
def references(self, *args): ... def references(self, *args): ...
def semicolonCount(self): ... def schema(self): ...
def semicolon_count(self): ...
def status(self): ... def status(self): ...
def yield_header_instances(self, enabled): ...
class Iterator: class Iterator:
def __init__(self, *args): ... def __init__(self, *args): ...
+1 -1
View File
@@ -1306,7 +1306,7 @@ from .entity_instance import entity_instance_mixin as _entity_instance_mixin_bas
%} %}
%extend ifcopenshell::instance_streamer<ifcopenshell::file_reader<ifcopenshell::full_buffer_impl>> { %extend ifcopenshell::instance_streamer<ifcopenshell::file_reader<ifcopenshell::full_buffer_impl>> {
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* { auto simply_type_to_dictionary = [&](const express::Base& t) -> PyObject* {
const auto& nm = t.declaration().name(); const auto& nm = t.declaration().name();
auto ifc_val = t.get_attribute_value(0); auto ifc_val = t.get_attribute_value(0);