lib.metadata
This library module implements the metadata handling for plugins and SmartHomeNG modules.
- class lib.metadata.Metadata(sh, addon_name, addon_type, classpath='')[Quellcode]
Bases:
object
- get_global_plugin_parameters()[Quellcode]
- get_plugin_function_defstrings(with_type=False, with_default=True)[Quellcode]
Build the documentation strings of the plugin’s functions
used e.g. for code completion in logic editor
- get_string(key)[Quellcode]
Return the value for a global key as a string
- Parameter:
key (str) – global key to look up (in section ‚plugin‘ or ‚module‘)
- Rückgabe:
value for the key
- Rückgabetyp:
str
- get_mlstring(mlkey)[Quellcode]
Return the value for a global multilanguage-key as a string
It trys to lookup th value for the default language. If the value for the default language is empty, it trys to look up the value for English. If there is no value for the default language and for English, it trys to lookup the value for German.
- Parameter:
key (str) – global multilanguage-key to look up (in section ‚plugin‘ or ‚module‘)
- Rückgabe:
value for the key
- Rückgabetyp:
str
- get_bool(key)[Quellcode]
Return the value for a global key as a bool
- Parameter:
key (str) – global key to look up (in section ‚plugin‘ or ‚module‘)
- Rückgabe:
value for the key
- Rückgabetyp:
bool
- test_shngcompatibility()[Quellcode]
Test if the actual running version of SmartHomeNG is in the range of supported versions for this addon (module/plugin)
- Rückgabe:
True if the SmartHomeNG version is in the supported range
- Rückgabetyp:
bool
- test_pythoncompatibility()[Quellcode]
Test if the actual running version of Python is in the range of supported versions for this addon (module/plugin)
- Rückgabe:
True if the Python version is in the supported range
- Rückgabetyp:
bool
- get_version()[Quellcode]
Returns the version of the addon
If test_version has been called before, the code_version is taken into account, otherwise the version of the metadata-file is returned
- Rückgabe:
version
- Rückgabetyp:
str
- test_version(code_version)[Quellcode]
Tests if the loaded Python code has a version set and compares it to the metadata version.
- Parameter:
code_version (str) – version of the python code
- Rückgabe:
True: version numbers match, or Python code has no version
- Rückgabetyp:
bool
- get_parameterlist()[Quellcode]
Returns the list of parameter names
- Rückgabe:
List of strings with parameter names
- Rückgabetyp:
list of str
- get_itemdefinitionlist()[Quellcode]
Returns the list of item attribute definitions
- Rückgabe:
List of strings with item attribute names
- Rückgabetyp:
list of str
- get_parameter_type(param)[Quellcode]
Returns the datatype of a parameter
- get_itemdefinition_type(definition)[Quellcode]
Returns the datatype of an item attribute definition
- get_parameter_subtype(param)[Quellcode]
Returns the subtype of a parameter
- get_itemdefinition_subtype(definition)[Quellcode]
Returns the subtype of an item attribute definition
- get_parameter_listlen(param)[Quellcode]
Returns the len of a parameter of type list of a parameter
- get_itemdefinition_listlen(definition)[Quellcode]
Returns the len of a parameter of type list of an item attribute definition
- get_parameter_type_with_subtype(param)[Quellcode]
Returns the datatype of a parameter with subtype (if subtype exists)
- get_itemdefinition_type_with_subtype(definition)[Quellcode]
Returns the datatype of an item attribute definition with subtype (if subtype exists)
- get_parameter_defaultvalue(param)[Quellcode]
Returns the default value for the parameter
- get_parameterdefinition(param, key)[Quellcode]
Returns the value for a key of a parameter as a string
- get_itemdefinition(definition, key)[Quellcode]
Returns the value for a key of a parameter as a string
- check_parameters(args)[Quellcode]
Checks the values of a dict of configured parameters.
Returns a dict with all defined parameters with values and a bool indicating if all parameters are ok (True) or if a mandatory parameter is not configured (False). It returns default values for parameters that have not been configured. The resulting dict contains the values in the the datatype of the parameter definition
- Parameter:
args (dict of parameter-values (values as string)) – Configured parameters with the values
- Rückgabe:
All defined parameters with values, Flag if all parameters are ok (no mandatory is missing)
- Rückgabetyp:
dict, bool
- check_itemattribute(item, attribute, value, defined_in_file=None)[Quellcode]
Checks the value of a plugin-specific item attribute and returnes the checked value or the default value if needed
attribute name is checked - against list of valid attributes-names (defined by section ‚item_attributes‘ of configured plugins) - against list of valid attribute-name prefixes (defined by section ‚item_attribute_prefixes‘ of configured plugins)
- Parameter:
item – item object
attribute –
value –
- Rückgabe: