From 091948e9efc7d8f012c7d287d12b715450c8dbe8 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Wed, 24 May 2023 11:33:12 -0700 Subject: [PATCH] ei-scanner: Fix `--jinja-extra-data-file`, and make `mypy` check pass --- proto/ei-scanner | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/proto/ei-scanner b/proto/ei-scanner index dd60ea7..aabebee 100755 --- a/proto/ei-scanner +++ b/proto/ei-scanner @@ -789,6 +789,7 @@ def generate_source( data["interfaces"] = proto.interfaces data["extra"] = extra_data + loader: jinja2.BaseLoader if template == "-": loader = jinja2.FunctionLoader(lambda _: sys.stdin.read()) filename = "" @@ -913,17 +914,17 @@ def main() -> None: extra_data = json.loads(ns.jinja_extra_data) elif ns.jinja_extra_data_file is not None: - if ns.jinja_extra_data.name.endswith( + if ns.jinja_extra_data_file.name.endswith( ".yml" - ) or ns.jinja_extra_data.name.endswith(".yaml"): + ) or ns.jinja_extra_data_file.name.endswith(".yaml"): import yaml - with open(ns.jinja_extra_data) as fd: + with open(ns.jinja_extra_data_file) as fd: extra_data = yaml.safe_load(fd) - elif ns.jinja_extra_data.name.endswith(".json"): + elif ns.jinja_extra_data_file.name.endswith(".json"): import json - with open(ns.jinja_extra_data) as fd: + with open(ns.jinja_extra_data_file) as fd: extra_data = json.load(fd) else: print("Unknown file format for jinja data", file=sys.stderr)