示例#1
0
    def wrapper(*args, **kwargs):
        mod_settings = kwargs.get('settings')
        kwargs['settings'] = mod_settings or settings

        if isinstance(kwargs['settings'], dict):
            kwargs['settings'] = settings.replace(mod_settings=mod_settings, **kwargs['settings'])

        if not isinstance(kwargs['settings'], Settings):
            raise TypeError("settings can only be either dict or instance of Settings class")

        return f(*args, **kwargs)
示例#2
0
    def wrapper(*args, **kwargs):
        kwargs['settings'] = kwargs.get('settings', settings)

        if kwargs['settings'] is None:
            kwargs['settings'] = settings

        if isinstance(kwargs['settings'], dict):
            kwargs['settings'] = settings.replace(**kwargs['settings'])

        if not isinstance(kwargs['settings'], Settings):
            raise TypeError(
                "settings can only be either dict or instance of Settings class")

        return f(*args, **kwargs)
示例#3
0
    def wrapper(*args, **kwargs):
        mod_settings = kwargs.get('settings', {})
        if mod_settings is None:
            kwargs['settings'], mod_settings = {}, {}

        if kwargs:
            if isinstance(mod_settings, dict):
                kwargs['settings'] = settings.replace(mod_settings=mod_settings.copy(), **kwargs)
        else:
            kwargs['settings'] = settings

        if not isinstance(kwargs['settings'], Settings):
            raise TypeError("settings can only be either dict or instance of Settings class")

        return f(*args, **kwargs)