mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 02:31:09 +00:00
Make validate module write to logger
This commit is contained in:
committed by
Thomas Krijnen
parent
fe633d9698
commit
f921b6a7e7
@@ -73,7 +73,7 @@ def try_valid(attr, val):
|
|||||||
except ValidationError as e:
|
except ValidationError as e:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def validate(f):
|
def validate(f, logger):
|
||||||
schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(f.schema)
|
schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(f.schema)
|
||||||
for inst in f:
|
for inst in f:
|
||||||
entity = schema.declaration_by_name(inst.is_a())
|
entity = schema.declaration_by_name(inst.is_a())
|
||||||
@@ -88,17 +88,22 @@ def validate(f):
|
|||||||
try:
|
try:
|
||||||
assert_valid(attr, val)
|
assert_valid(attr, val)
|
||||||
except ValidationError as e:
|
except ValidationError as e:
|
||||||
print("In", inst)
|
logger.error('In {}\n{}'.format(inst, e))
|
||||||
print(e)
|
|
||||||
print()
|
|
||||||
|
|
||||||
for attr in entity.all_inverse_attributes():
|
for attr in entity.all_inverse_attributes():
|
||||||
val = getattr(inst, attr.name())
|
val = getattr(inst, attr.name())
|
||||||
assert_valid_inverse(attr, val)
|
try:
|
||||||
|
assert_valid_inverse(attr, val)
|
||||||
|
except ValidationError as e:
|
||||||
|
logger.error('In {}\n{}'.format(inst, e))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import sys
|
import sys
|
||||||
|
import logging
|
||||||
|
|
||||||
for fn in sys.argv[1:]:
|
for fn in sys.argv[1:]:
|
||||||
|
logger = logging.getLogger('validate')
|
||||||
|
logger.setLevel(logging.DEBUG)
|
||||||
print("Validating", fn)
|
print("Validating", fn)
|
||||||
validate(ifcopenshell.open(fn))
|
validate(ifcopenshell.open(fn), logger)
|
||||||
|
|||||||
Reference in New Issue
Block a user