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
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
@@ -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:
@@ -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): ...
+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>> {
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);