def validate_component(formula, repodir, component):
    from .tasks import FormulaTaskException
    # check for required fields
    if 'title' not in component or 'sls_path' not in component:
        raise FormulaTaskException(
            formula,
            'Each component in the SPECFILE must contain a \'title\' '
            'and \'sls_path\' field.')

    # determine if the sls_path is valid...we're looking for either
    # a directory with an init.sls or an sls file of the same name
    # as the last location of the path
    component_title = component['title']
    sls_path = component['sls_path'].replace('.', '/')
    init_file = os.path.join(sls_path, 'init.sls')
    sls_file = sls_path + '.sls'
    abs_init_file = os.path.join(repodir, init_file)
    abs_sls_file = os.path.join(repodir, sls_file)

    if not os.path.isfile(abs_init_file) and not os.path.isfile(abs_sls_file):
        raise FormulaTaskException(
            formula,
            'Could not locate an SLS file for component \'{0}\'. '
            'Expected to find either \'{1}\' or \'{2}\'.'.format(component_title,
                                                                 init_file,
                                                                 sls_file)
        )
dataset/ETHPy150Open stackdio/stackdio/stackdio/api/formulas/validators.py/validate_component/original