mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
ifctester.main - fail more gracefully for invalid files
This commit is contained in:
@@ -23,6 +23,7 @@ import argparse
|
||||
import ifcopenshell
|
||||
from . import ids
|
||||
from . import reporter
|
||||
from pathlib import Path
|
||||
|
||||
parser = argparse.ArgumentParser(description="Uses an IDS to audit an IFC")
|
||||
parser.add_argument("ids", type=str, help="Path to an IDS")
|
||||
@@ -33,10 +34,19 @@ parser.add_argument("--excel-safe", help="Make sure exported ODS is safely expor
|
||||
parser.add_argument("-o", "--output", help="Output file (supported for all types of reporting except Console)")
|
||||
args = parser.parse_args()
|
||||
|
||||
specs = ids.open(args.ids)
|
||||
ids_path = Path(args.ids)
|
||||
if ids_path.suffix.lower() != ".ids":
|
||||
raise Exception(f"Provided file is not an .ids file: '{ids_path}'.")
|
||||
|
||||
ifc_patch = Path(args.ifc)
|
||||
if ifc_patch.suffix.lower() != ".ifc":
|
||||
raise Exception(f"Provided file is not an .ifc file: '{ifc_patch}'.")
|
||||
|
||||
specs = ids.open(str(ids_path))
|
||||
if args.ifc:
|
||||
start = time.time()
|
||||
ifc = ifcopenshell.open(args.ifc)
|
||||
ifc = ifcopenshell.open(ifc_patch)
|
||||
assert isinstance(ifc, ifcopenshell.file)
|
||||
print("Finished loading:", time.time() - start)
|
||||
start = time.time()
|
||||
specs.validate(ifc)
|
||||
|
||||
Reference in New Issue
Block a user