# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 Graz University of Technology.
#
# invenio-imoox is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.

"""Provides API for iMooX."""

from . import config


class InvenioIMooX:
    """invenio-imoox extension."""

    def __init__(self, app=None):
        """Extension initialization."""
        if app:
            self.init_app(app)

    def init_app(self, app):
        """Flask application initialization."""
        self.init_config(app)
        app.extensions["invenio-imoox"] = self

    def init_config(self, app):  # pylint: disable=no-self-use
        """Initialize configuration."""
        for k in dir(config):
            if k.startswith("INVENIO_IMOOX_"):
                app.config.setdefault(k, getattr(config, k))
