mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 14:23:53 +00:00
hacky way to retain attribute too many messages on header entities in validate.py
This commit is contained in:
@@ -320,14 +320,16 @@ def log_internal_cpp_errors(
|
|||||||
|
|
||||||
chr_offset_re = re.compile(r"at offset (\d+)\s*")
|
chr_offset_re = re.compile(r"at offset (\d+)\s*")
|
||||||
for_instance_re = re.compile(r"\s*for instance #(\d+)\s*")
|
for_instance_re = re.compile(r"\s*for instance #(\d+)\s*")
|
||||||
|
for_header_ent_re = re.compile(r"\s*for header entity (\w+)")
|
||||||
|
|
||||||
if log_content is None:
|
if log_content is None:
|
||||||
log_content = ifcopenshell.get_log()
|
log_content = ifcopenshell.get_log()
|
||||||
msgs = list(map(json.loads, filter(None, log_content.split("\n"))))
|
msgs = list(map(json.loads, filter(None, log_content.split("\n"))))
|
||||||
chr_offsets = [chr_offset_re.findall(m["message"]) for m in msgs]
|
chr_offsets = [chr_offset_re.findall(m["message"]) for m in msgs]
|
||||||
instance_messages = [for_instance_re.findall(m["message"]) for m in msgs]
|
instance_messages = [for_instance_re.findall(m["message"]) for m in msgs]
|
||||||
|
header_messages = [for_header_ent_re.findall(m["message"]) for m in msgs]
|
||||||
|
|
||||||
if chr_offsets or (instance_messages and f is None):
|
if any(chr_offsets) or (any(instance_messages) and f is None):
|
||||||
# The file is opened in binary mode, in order
|
# The file is opened in binary mode, in order
|
||||||
# to correspond with the offsets reported by
|
# to correspond with the offsets reported by
|
||||||
# IfcOpenShell C++
|
# IfcOpenShell C++
|
||||||
@@ -348,7 +350,7 @@ def log_internal_cpp_errors(
|
|||||||
else:
|
else:
|
||||||
logger.error("For instance:\n %s\n%s", line, m)
|
logger.error("For instance:\n %s\n%s", line, m)
|
||||||
|
|
||||||
if instance_messages:
|
if any(instance_messages):
|
||||||
for instid, msg in zip(instance_messages, msgs):
|
for instid, msg in zip(instance_messages, msgs):
|
||||||
if instid:
|
if instid:
|
||||||
m = for_instance_re.sub("", msg["message"])
|
m = for_instance_re.sub("", msg["message"])
|
||||||
@@ -376,6 +378,12 @@ def log_internal_cpp_errors(
|
|||||||
else:
|
else:
|
||||||
logger.error(m)
|
logger.error(m)
|
||||||
|
|
||||||
|
if any(header_messages):
|
||||||
|
for hent, msg in zip(header_messages, msgs):
|
||||||
|
if hent:
|
||||||
|
m = msg["message"]
|
||||||
|
logger.error(m)
|
||||||
|
|
||||||
|
|
||||||
entity_attribute_map: dict[tuple[str, str], tuple[entity_type, tuple[attribute, ...]]] = {}
|
entity_attribute_map: dict[tuple[str, str], tuple[entity_type, tuple[attribute, ...]]] = {}
|
||||||
|
|
||||||
|
|||||||
@@ -259,7 +259,11 @@ IfcEntityInstanceData IfcParse::parse_context::construct(boost::optional<size_t>
|
|||||||
expected_size && *expected_size != tokens_.size())
|
expected_size && *expected_size != tokens_.size())
|
||||||
{
|
{
|
||||||
size_t expected = expected_size ? *expected_size : parameter_types.size();
|
size_t expected = expected_size ? *expected_size : parameter_types.size();
|
||||||
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("")));
|
if (decl != nullptr && decl->schema() == &Header_section_schema::get_schema()) {
|
||||||
|
Logger::Warning("Expected " + std::to_string(expected) + " attribute values, found " + std::to_string(tokens_.size()) + " for header entity " + decl->name());
|
||||||
|
} else {
|
||||||
|
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("")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tokens_.empty()) {
|
if (tokens_.empty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user