def get_application(context, application):
    """
    Get Application class instance of an application, based upon given name.

    :type context: <behave.runner.Context>
    :param context: Context object that is passed from common_steps.

    :type application: str
    :param application: String of application identification: name.

    :rtype: <qecore.application.Application>
    :return: Application class instance

    .. note::

        Do **NOT** call this by yourself. This function is called by :mod:`common_steps`.
    """
    app_class_to_return = None
    try:
        app_class_to_return = getattr(context, application)
    except AttributeError:
        for app in context.sandbox.applications:
            if app.component == application:
                app_class_to_return = app
                break
    except TypeError:
        app_class_to_return = context.sandbox.default_application
        assert context.sandbox.default_application is not None, 'Default application was not found. Check your environment file!'
    assert app_class_to_return is not None, 'Application was not found. Check your environment or feature file!'
    assert not isinstance(app_class_to_return, str
        ), 'Application class was not found. Usually indication of not installed application.'
    return app_class_to_return
