mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-04-13 05:00:39 +02:00
ei-scanner: Fix --jinja-extra-data-file, and make mypy check pass
This commit is contained in:
parent
016072507e
commit
091948e9ef
1 changed files with 6 additions and 5 deletions
|
|
@ -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 = "<stdin>"
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue