mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 18:43:26 +00:00
Fix #3059. Implement IfcTester prohibited string templates (taking into account double negatives)
This commit is contained in:
@@ -85,11 +85,16 @@ class Facet:
|
||||
def filter(self, ifc_file, elements):
|
||||
return [e for e in elements if self(e)]
|
||||
|
||||
def to_string(self, clause_type):
|
||||
def to_string(self, clause_type, specification=None, requirement=None):
|
||||
if clause_type == "applicability":
|
||||
templates = self.applicability_templates
|
||||
elif clause_type == "requirement":
|
||||
templates = self.requirement_templates
|
||||
is_prohibited = False
|
||||
if specification.maxOccurs == 0:
|
||||
is_prohibited = not is_prohibited
|
||||
if requirement.maxOccurs == 0:
|
||||
is_prohibited = not is_prohibited
|
||||
templates = self.prohibited_templates if is_prohibited else self.requirement_templates
|
||||
|
||||
for template in templates:
|
||||
total_variables = len(template) - len(template.replace("{", ""))
|
||||
@@ -139,6 +144,10 @@ class Entity(Facet):
|
||||
"Shall be {name} data of type {predefinedType}",
|
||||
"Shall be {name} data",
|
||||
]
|
||||
self.prohibited_templates = [
|
||||
"Shall not be {name} data of type {predefinedType}",
|
||||
"Shall not be {name} data",
|
||||
]
|
||||
super().__init__(name, predefinedType, instructions)
|
||||
|
||||
def filter(self, ifc_file, elements):
|
||||
@@ -192,6 +201,10 @@ class Attribute(Facet):
|
||||
"The {name} shall be {value}",
|
||||
"The {name} shall be provided",
|
||||
]
|
||||
self.prohibited_templates = [
|
||||
"The {name} shall not be {value}",
|
||||
"The {name} shall not be provided",
|
||||
]
|
||||
super().__init__(name, value, minOccurs, maxOccurs, instructions)
|
||||
|
||||
def filter(self, ifc_file, elements):
|
||||
@@ -311,6 +324,13 @@ class Classification(Facet):
|
||||
"Shall be classified as {value}",
|
||||
"Shall be classified",
|
||||
]
|
||||
self.prohibited_templates = [
|
||||
"Shall not have a {system} reference of {value}",
|
||||
"Shall not be classified using {system}",
|
||||
"Shall not be classified as {value}",
|
||||
"Shall not be classified",
|
||||
]
|
||||
|
||||
super().__init__(value, system, uri, minOccurs, maxOccurs, instructions)
|
||||
|
||||
def filter(self, ifc_file, elements):
|
||||
@@ -370,6 +390,10 @@ class PartOf(Facet):
|
||||
"An element must have an {relation} relationship with an {name}",
|
||||
"An element must have an {relation} relationship",
|
||||
]
|
||||
self.prohibited_templates = [
|
||||
"An element must not have an {relation} relationship with an {name}",
|
||||
"An element must not have an {relation} relationship",
|
||||
]
|
||||
super().__init__(name, predefinedType, relation, minOccurs, maxOccurs, instructions)
|
||||
|
||||
def filter(self, ifc_file, elements):
|
||||
@@ -584,6 +608,10 @@ class Property(Facet):
|
||||
"{name} data shall be {value} and in the dataset {propertySet}",
|
||||
"{name} data shall be provided in the dataset {propertySet}",
|
||||
]
|
||||
self.prohibited_templates = [
|
||||
"{name} data shall not be {value} and in the dataset {propertySet}",
|
||||
"{name} data shall not be provided in the dataset {propertySet}",
|
||||
]
|
||||
super().__init__(propertySet, name, value, datatype, uri, minOccurs, maxOccurs, instructions)
|
||||
|
||||
def filter(self, ifc_file, elements):
|
||||
@@ -845,6 +873,10 @@ class Material(Facet):
|
||||
"Shall have a material of {value}",
|
||||
"Shall have a material",
|
||||
]
|
||||
self.prohibited_templates = [
|
||||
"Shall not have a material of {value}",
|
||||
"Shall not have a material",
|
||||
]
|
||||
super().__init__(value, uri, minOccurs, maxOccurs, instructions)
|
||||
|
||||
def filter(self, ifc_file, elements):
|
||||
|
||||
@@ -106,7 +106,7 @@ class Console(Reporter):
|
||||
for requirement in specification.requirements:
|
||||
self.set_style("reset")
|
||||
self.set_style("red") if requirement.failed_entities else self.set_style("green")
|
||||
self.print(" " * 8 + requirement.to_string("requirement"))
|
||||
self.print(" " * 8 + requirement.to_string("requirement", specification, requirement))
|
||||
self.set_style("reset")
|
||||
for i, element in enumerate(requirement.failed_entities[0:10]):
|
||||
self.print(" " * 12, end="")
|
||||
@@ -217,7 +217,7 @@ class Json(Reporter):
|
||||
total_checks_pass += total_pass
|
||||
requirements.append(
|
||||
{
|
||||
"description": requirement.to_string("requirement") if specification.maxOccurs != 0 else requirement.to_string("requirement").replace('shall', 'shall not'),
|
||||
"description": requirement.to_string("requirement", specification, requirement),
|
||||
"status": requirement.status,
|
||||
"failed_entities": self.report_failed_entities(requirement),
|
||||
"total_applicable": total_applicable,
|
||||
|
||||
Reference in New Issue
Block a user