Application¶
-
class
ocvproto.app.application.
Application
(*, config: Union[str, pathlib.Path, None] = None)¶ Represents ocvproto application.
Parameters: config – Configuration to be used. -
bind_key
(key: Union[str, int], func: Callable)¶ Binds a key to a function.
Parameters: - key –
- func –
-
config_load
()¶ Loads a configuration from config file.
-
config_save
()¶ Saves current configuration to config file.
-
hook_register
(key: str, func: Callable)¶ Registers a hook.
Parameters: - key – Hooks group key.
- func – Hook function to add to group.
-
loop
()¶ Main application loop. Handles keys listening and issues a loop function (see .set_loop_func()).
-
set_config
(config: Union[str, pathlib.Path, None], keys: Tuple[Union[str, int], Union[str, int]] = None)¶ Sets configuration from the app.
Parameters: - config – Configuration object.
- keys – Keys tuple to save and load configuration.
-
set_loop_func
(func: Callable)¶ Sets a function to perform in a main app loop.
-
Config¶
-
class
ocvproto.app.config.
Config
(fpath: Union[str, pathlib.Path])¶ Represent an interface to configuration file.
Parameters: fpath – Configuration file path. -
get_data
(key: str, default: Any = None)¶ Reads data from a config section denoted by key.
Parameters: - key –
- default – Default values to return.
-
load
()¶ Loads configuration from file.
-
save
()¶ Saves configuration to file.
-
set_data
(key: str, value: Any)¶ Places the data into config section denoted by key.
Parameters: - key –
- value –
-