openstb.simulator.plugin.util
Functions:
| Name | Description |
|---|---|
find_config_loader |
Try to find a config loader plugin. |
load_config_plugins |
Load configuration plugins. |
find_config_loader
find_config_loader(source)
Try to find a config loader plugin.
This is intended for use in a user interface. Given the source (e.g, the filename)
of the desired configuration, it searches through the registered ConfigLoader
plugins for one which says it might be able to handle it.
Note that the plugins may return false positives or false negatives when asked about
their ability to handle a source (see the could_handle method of the
ConfigLoader class for details). If a class is returned, there is no guarantee it
will actually be able to handle a source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
The provided configuration source. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
name |
(str, None)
|
The name of the plugin to use, or None if no plugin was found. |
cls |
(ConfigLoader, None)
|
The plugin to use, or None if no plugin was found. |
Source code in openstb/simulator/plugin/util.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
load_config_plugins
load_config_plugins(config_class, config, missing='error', extra='error', unhandled_type='error', **keys)
Load configuration plugins.
This uses a mapping of config keys to type annotations, either extracted from the
configuration class or given as keyword arguments, to tell it what type of plugin
is expected for each key. It then checks for a function registered with the
openstb.simulator.plugin.loader.register_loader decorator to convert the entry in
the configuration dictionary to a plugin instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_class
|
type
|
The class (not an instance of the class) specifying the configuration structure.
This would typically be a subclass of |
required |
config
|
mapping
|
The current configuration. This will be modified in-place. |
required |
missing
|
(error, warn, ignore)
|
How to handle missing, extra (unknown) entries in |
"error"
|
extra
|
(error, warn, ignore)
|
How to handle missing, extra (unknown) entries in |
"error"
|
unhandled_type
|
(error, warn, ignore)
|
How to handle missing, extra (unknown) entries in |
"error"
|
**keys
|
Keyword arguments can be given to map the keys in |
{}
|
Source code in openstb/simulator/plugin/util.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |