mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 22:11:36 +00:00
ifctester.main - fail more gracefully for invalid files
This commit is contained in:
@@ -23,6 +23,7 @@ import argparse
|
|||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
from . import ids
|
from . import ids
|
||||||
from . import reporter
|
from . import reporter
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Uses an IDS to audit an IFC")
|
parser = argparse.ArgumentParser(description="Uses an IDS to audit an IFC")
|
||||||
parser.add_argument("ids", type=str, help="Path to an IDS")
|
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)")
|
parser.add_argument("-o", "--output", help="Output file (supported for all types of reporting except Console)")
|
||||||
args = parser.parse_args()
|
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:
|
if args.ifc:
|
||||||
start = time.time()
|
start = time.time()
|
||||||
ifc = ifcopenshell.open(args.ifc)
|
ifc = ifcopenshell.open(ifc_patch)
|
||||||
|
assert isinstance(ifc, ifcopenshell.file)
|
||||||
print("Finished loading:", time.time() - start)
|
print("Finished loading:", time.time() - start)
|
||||||
start = time.time()
|
start = time.time()
|
||||||
specs.validate(ifc)
|
specs.validate(ifc)
|
||||||
|
|||||||
Reference in New Issue
Block a user