Add config field for script config
This commit is contained in:
parent
f590e752be
commit
58e2b09b8a
@ -1,6 +1,7 @@
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import json
|
import json
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from microkodi.helpers import recursive_dict_merge
|
from microkodi.helpers import recursive_dict_merge
|
||||||
|
|
||||||
@ -34,12 +35,8 @@ class Config:
|
|||||||
# URL scheme -> netloc (or '*' for fallback) -> fully-qualified player class
|
# URL scheme -> netloc (or '*' for fallback) -> fully-qualified player class
|
||||||
players: dict[str, dict[str, str]]
|
players: dict[str, dict[str, str]]
|
||||||
|
|
||||||
card: str | None
|
# The entire configuration file for use in user scripts
|
||||||
connector: str | None
|
options: dict[str, Any]
|
||||||
|
|
||||||
@property
|
|
||||||
def watch_connector(self) -> bool:
|
|
||||||
return self.card is not None and self.connector is not None
|
|
||||||
|
|
||||||
def load_config(config_path: Path | None) -> Config:
|
def load_config(config_path: Path | None) -> Config:
|
||||||
if config_path is None:
|
if config_path is None:
|
||||||
@ -66,6 +63,5 @@ def load_config(config_path: Path | None) -> Config:
|
|||||||
},
|
},
|
||||||
config_data.get("players", {}),
|
config_data.get("players", {}),
|
||||||
),
|
),
|
||||||
card=config_data.get("card"),
|
options=config_data.get("options", {}),
|
||||||
connector=config_data.get("connector"),
|
|
||||||
)
|
)
|
||||||
|
@ -91,10 +91,6 @@ if __name__ == "__main__":
|
|||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
engine.rootObjects()[0].setProperty("bridge", bridge)
|
engine.rootObjects()[0].setProperty("bridge", bridge)
|
||||||
|
|
||||||
if config.watch_connector:
|
|
||||||
logger.info("Will be watching display if it's gone")
|
|
||||||
|
|
||||||
exit_code = app.exec()
|
exit_code = app.exec()
|
||||||
del engine
|
del engine
|
||||||
sys.exit(exit_code)
|
sys.exit(exit_code)
|
Loading…
Reference in New Issue
Block a user