Exemplo n.º 1
0
    def __init__(self, raw_songbook, basename):
        # Validate config
        schema = config_model('schema', alt_dir=raw_songbook['_datadir'][0])

        try:
            utils.validate_yaml_schema(raw_songbook, schema)
        except errors.SchemaError as exception:
            exception.message = "The songbook file '{}' is not valid\n".format(basename)
            raise exception

        self._raw_config = raw_songbook
        self.basename = basename
        self._errors = list()
        self._config = dict()
Exemplo n.º 2
0
    def __init__(self, raw_songbook, basename):
        # Validate config
        schema = config_model('schema')

        try:
            utils.validate_yaml_schema(raw_songbook, schema)
        except errors.SchemaError as exception:
            exception.message = "The songbook file '{}' is not valid\n".format(basename)
            raise exception

        self._raw_config = raw_songbook
        self.basename = basename
        self._errors = list()
        self._config = dict()
Exemplo n.º 3
0
    def _get_variables(parameter, user_config, lang):
        '''Get the default value for the parameter, according to the language.

        Will raise `SchemaError` if the data does not respect the schema
        '''
        locale_default = parameter.get('default', {})
        # Initialize with default in english
        data = locale_default.get('en', {})
        data = utils.DictOfDict(data)

        # Update default with current lang
        data.update(locale_default.get(lang, {}))
        # Update default with user_config
        data.update(user_config)

        schema = parameter.get('schema', {})
        utils.validate_yaml_schema(data, schema)

        return data
Exemplo n.º 4
0
    def _get_variables(parameter, user_config, lang):
        '''Get the default value for the parameter, according to the language.

        Will raise `SchemaError` if the data does not respect the schema
        '''
        locale_default = parameter.get('default', {})
        # Initialize with default in english
        data = locale_default.get('en', {})
        data = utils.DictOfDict(data)

        # Update default with current lang
        data.update(locale_default.get(lang, {}))
        # Update default with user_config
        data.update(user_config)

        schema = parameter.get('schema', {})
        utils.validate_yaml_schema(data, schema)

        return data