diff --git a/checker.py b/checker.py index 3c1f9a0..38a3a34 100644 --- a/checker.py +++ b/checker.py @@ -46,7 +46,7 @@ def main(files: List[str], draw_cfg: str = "", parser.add_argument("files", nargs='*', help="Path to IEC source files") parser.add_argument("--draw-cfg", type=str, help="Save control flow graph image at the selected path") - parser.add_argument("-b","--binary", default=os.path.join("output", "bin", "iec_checker"), + parser.add_argument("-b", "--binary", default=os.path.join("output", "bin", "iec_checker"), help="File path to the OCaml binary") args = parser.parse_args() sys.exit(main(args.files, args.draw_cfg, args.binary)) diff --git a/src/python/core.py b/src/python/core.py index c752269..cb881e3 100644 --- a/src/python/core.py +++ b/src/python/core.py @@ -52,7 +52,7 @@ def run_checker(file_path: str, binary: str = binary_default, def run_checker_full_out(file_path: str, binary: str = binary_default, - *args) -> Tuple[int, str]: + *args) -> Tuple[int, str]: """Run iec-checker core for a given file and capture the whole output. No extra options will be set by default.""" p = subprocess.Popen([binary, *args, file_path], diff --git a/src/python/dump.py b/src/python/dump.py index 3dfe1e9..753c6a1 100644 --- a/src/python/dump.py +++ b/src/python/dump.py @@ -4,7 +4,7 @@ import os import logging from dataclasses import dataclass -from typing import List +from typing import List, Optional import ijson from .om import Scheme @@ -30,7 +30,7 @@ class DumpManager: def __init__(self, dump_path: str): self.dump_path: str = dump_path - self.scheme: Scheme = None + self.scheme: Optional[Scheme] = None def __enter__(self): self.scheme = self.mk_scheme() @@ -51,6 +51,8 @@ def mk_scheme(self) -> Scheme: with open(self.dump_path, 'rb') as f: for item in ijson.items(f, ""): scheme = Scheme.from_dict(item) + if not scheme: + raise Exception(f"Cannot parse JSON scheme from {self.dump_path}") return scheme def remove_dump(self): diff --git a/src/python/om.py b/src/python/om.py index c4ee34f..40f9365 100644 --- a/src/python/om.py +++ b/src/python/om.py @@ -1,7 +1,6 @@ """Object model The Object model represents IR data from the iec-checker core. """ - from dataclasses import dataclass from typing import List, Dict, Set