How to use the shyaml.yaml_load function in shyaml

To help you get started, we’ve selected a few shyaml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github smarthomeNG / smarthome / doc / build_plugin_config_files.py View on Github external
def build_pluginlist( plugin_type='all' ):
    """
    Return a list of dicts with a dict for each plugin of the requested type
    The dict contains the plugin name, type and description
    """
    result = []
    plugin_type = plugin_type.lower()
    for metaplugin in plugins_git:
        metafile = metaplugin + '/plugin.yaml'
        plg_dict = {}
        if metaplugin in plugins_git:    #pluginsyaml_git
            if os.path.isfile(metafile):
                plugin_yaml = shyaml.yaml_load(metafile, ordered=True)
            else:
                plugin_yaml = ''
            if plugin_yaml != '':
                section_dict = plugin_yaml.get('plugin')
                if section_dict != None:
                    if section_dict.get('type') != None:
                        if section_dict.get('type').lower() in plugin_types:
                            plgtype = section_dict.get('type').lower()
                            plg_dict['name'] = metaplugin.lower()
                            plg_dict['type'] = plgtype
                            plg_dict['desc'] = get_description(section_dict, 85, language)
                            plg_dict['maint'] = get_maintainer(section_dict, 15)
                            plg_dict['test'] = get_tester(section_dict, 15)
                            plg_dict['doc'] = html_escape(section_dict.get('documentation', ''))
                            plg_dict['sup'] = html_escape(section_dict.get('support', ''))
                        else:
github smarthomeNG / smarthome / doc / build_plugin_rst_files.py View on Github external
def build_pluginlist( plugin_type='all' ):
    """
    Return a list of dicts with a dict for each plugin of the requested type
    The dict contains the plugin name, type and description
    """
    result = []
    plugin_type = plugin_type.lower()
    for metaplugin in plugins_git:
        metafile = metaplugin + '/plugin.yaml'
        plg_dict = {}
        if metaplugin in plugins_git:    #pluginsyaml_git
            if os.path.isfile(metafile):
                plugin_yaml = shyaml.yaml_load(metafile)
            else:
                plugin_yaml = ''
            if plugin_yaml != '':
                section_dict = plugin_yaml.get('plugin')
                if section_dict != None:
                    if section_dict.get('type') != None:
                        if section_dict.get('type').lower() in plugin_types:
                            plgtype = section_dict.get('type').lower()
                            plg_dict['name'] = metaplugin.lower()
                            plg_dict['type'] = plgtype
                            plg_dict['desc'] = get_description(section_dict, 85, language)
                            plg_dict['maint'] = get_maintainer(section_dict, 15)
                            plg_dict['test'] = get_tester(section_dict, 15)
                            plg_dict['doc'] = html_escape(section_dict.get('documentation', ''))
                            plg_dict['sup'] = html_escape(section_dict.get('support', ''))
                        else:
github smarthomeNG / smarthome / doc / build_plugin_config_files.py View on Github external
def write_configfile(plg, configfile_dir, language='de'):
    """
    Create a .rst file with configuration information for the passed plugin
    """
    plgname = plg['name']

    # ---------------------------------
    # read metadata for plugin
    # ---------------------------------
    metafile = plgname + '/plugin.yaml'
    if os.path.isfile(metafile):
        meta_yaml = shyaml.yaml_load(metafile, ordered=True)
        plugin_yaml = meta_yaml.get('plugin', {})
        parameter_yaml = meta_yaml.get('parameters', {})
        iattributes_yaml = meta_yaml.get('item_attributes', {})
        lparameter_yaml = meta_yaml.get('logic_parameter', {})
        functions_yaml = meta_yaml.get('plugin_functions', {})

        no_parameters = (parameter_yaml == 'NONE')
        if no_parameters or parameter_yaml is None:
            parameter_yaml = {}

        no_attributes = (iattributes_yaml == 'NONE')
        if no_attributes or iattributes_yaml is None:
            iattributes_yaml = {}

        no_lparameters = (lparameter_yaml == 'NONE')
        if no_lparameters or lparameter_yaml is None:
github smarthomeNG / smarthome / tools / plugin_metadata_checker.py View on Github external
def readMetadata(metaplugin, plugins_local):

    metafile = metaplugin + '/plugin.yaml'
    plg_dict = {}
    plugin_yaml = {}
    if metaplugin in plugins_local:  # pluginsyaml_local
        if os.path.isfile(metafile):
            plugin_yaml = shyaml.yaml_load(metafile, ordered=True)
    else:
        print("There is no plugin named '" + metaplugin + "'")
        print()
        return None
    return plugin_yaml