def _validate_config(self):
        """ ensure REQUIRED_CONFIG_KEYS are filled """
        # exit if no backend specified
        if not self.backend:
            return
        # exit if no required config keys
        if len(self.REQUIRED_CONFIG_KEYS) < 1:
            return

        self.config = self.config or {}  # default to empty dict of no config
        required_keys_set = set(self.REQUIRED_CONFIG_KEYS)
        config_keys_set = set(self.config.keys())
        missing_required_keys = required_keys_set - config_keys_set
        unrecognized_keys = config_keys_set - required_keys_set

        # if any missing required key raise ValidationError
        if len(missing_required_keys) > 0:
            # converts list in comma separated string
            missing_keys_string = ', '.join(missing_required_keys)
            # django error
            raise ValidationError(_('Missing required config keys: "%s"') % missing_keys_string)
        elif len(unrecognized_keys) > 0:
            # converts list in comma separated string
            unrecognized_keys_string = ', '.join(unrecognized_keys)
            # django error
            raise ValidationError(_('Unrecognized config keys: "%s"') % unrecognized_keys_string)
def _validate_config ( self ) : if not self . backend : return if len ( self . REQUIRED_CONFIG_KEYS ) < 1 : return self . config = self . config or { } required_keys_set = set ( self . REQUIRED_CONFIG_KEYS ) config_keys_set = set ( self . config . keys ( ) ) missing_required_keys = required_keys_set - config_keys_set unrecognized_keys = config_keys_set - required_keys_set if len ( missing_required_keys ) > 0 : missing_keys_string = ', ' . join ( missing_required_keys ) raise ValidationError ( _ ( 'Missing required config keys: "%s"' ) % missing_keys_string ) elif len ( unrecognized_keys ) > 0 : unrecognized_keys_string = ', ' . join ( unrecognized_keys ) raise ValidationError ( _ ( 'Unrecognized config keys: "%s"' ) % unrecognized_keys_string )
ensure REQUIRED_CONFIG_KEYS are filled