Skip to content

Commit 7cb1f07

Browse files
committed
hacky way to retain attribute too many messages on header entities in validate.py
1 parent bdb52dc commit 7cb1f07

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/ifcopenshell-python/ifcopenshell/validate.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,16 @@ def log_internal_cpp_errors(
320320

321321
chr_offset_re = re.compile(r"at offset (\d+)\s*")
322322
for_instance_re = re.compile(r"\s*for instance #(\d+)\s*")
323+
for_header_ent_re = re.compile(r"\s*for header entity (\w+)")
323324

324325
if log_content is None:
325326
log_content = ifcopenshell.get_log()
326327
msgs = list(map(json.loads, filter(None, log_content.split("\n"))))
327328
chr_offsets = [chr_offset_re.findall(m["message"]) for m in msgs]
328329
instance_messages = [for_instance_re.findall(m["message"]) for m in msgs]
330+
header_messages = [for_header_ent_re.findall(m["message"]) for m in msgs]
329331

330-
if chr_offsets or (instance_messages and f is None):
332+
if any(chr_offsets) or (any(instance_messages) and f is None):
331333
# The file is opened in binary mode, in order
332334
# to correspond with the offsets reported by
333335
# IfcOpenShell C++
@@ -348,7 +350,7 @@ def log_internal_cpp_errors(
348350
else:
349351
logger.error("For instance:\n %s\n%s", line, m)
350352

351-
if instance_messages:
353+
if any(instance_messages):
352354
for instid, msg in zip(instance_messages, msgs):
353355
if instid:
354356
m = for_instance_re.sub("", msg["message"])
@@ -376,6 +378,12 @@ def log_internal_cpp_errors(
376378
else:
377379
logger.error(m)
378380

381+
if any(header_messages):
382+
for hent, msg in zip(header_messages, msgs):
383+
if hent:
384+
m = msg["message"]
385+
logger.error(m)
386+
379387

380388
entity_attribute_map: dict[tuple[str, str], tuple[entity_type, tuple[attribute, ...]]] = {}
381389

src/ifcparse/IfcFile.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,11 @@ IfcEntityInstanceData IfcParse::parse_context::construct(boost::optional<size_t>
259259
expected_size && *expected_size != tokens_.size())
260260
{
261261
size_t expected = expected_size ? *expected_size : parameter_types.size();
262-
Logger::Warning("Expected " + std::to_string(expected) + " attribute values, found " + std::to_string(tokens_.size()) + (name ? std::string(" for instance #" + std::to_string(*name)) : std::string("")));
262+
if (decl != nullptr && decl->schema() == &Header_section_schema::get_schema()) {
263+
Logger::Warning("Expected " + std::to_string(expected) + " attribute values, found " + std::to_string(tokens_.size()) + " for header entity " + decl->name());
264+
} else {
265+
Logger::Warning("Expected " + std::to_string(expected) + " attribute values, found " + std::to_string(tokens_.size()) + (name ? std::string(" for instance #" + std::to_string(*name)) : std::string("")));
266+
}
263267
}
264268

265269
if (tokens_.empty()) {

0 commit comments

Comments
 (0)