Пример #1
0
    def _validate_config(cls, config):
        """
        Helper method for preventing config errors
        """
        COLUMN_MAP = config.get('COLUMN_MAP', None)

        if COLUMN_MAP is None:
            raise ConfigErr(
                "Please verify that the config specifies the `COLUMN_MAP` parameter!"
            )  # noqa

        # Verify that every required column is mapped
        CONFIGURED_COLS = list(COLUMN_MAP.keys())
        diff = list(set(REQUIRED_COLS).difference(CONFIGURED_COLS))
        cls.log.info('REQUIRED_COLS: {}'.format(REQUIRED_COLS))
        cls.log.info('CONFIGURED_COLS: {}'.format(CONFIGURED_COLS))

        if len(diff) > 0:
            raise ConfigErr(
                'Please verify that the config specifies every column in the `COLUMN_MAP` parameter! Missing: {}'
                .format(diff))  # noqa

        enabled_rules = config.get('ENABLED_RULES', None)

        if not enabled_rules:
            raise ConfigErr(
                'Please verify that the config specifies the `ENABLED_RULES` parameter!'
            )  # noqa

        for rule_code in enabled_rules:
            if rule_code not in rulz:
                raise ConfigErr(
                    'Invalid rule: [{}]! Available codes are: {}'.format(
                        rule_code, rulz.keys()))
Пример #2
0
    def _validate_config(cls, config):
        """
        Helper method for preventing config errors
        """
        enabled_rules = config.get('ENABLED_RULES', None)

        if not enabled_rules:
            raise ConfigErr('Please verify that the config specifies'
                            ' the `ENABLED_RULES` parameter!')

        for rule_code in enabled_rules:
            if rule_code not in rulz:
                raise ConfigErr('Invalid rule code: [{}]!'
                                ' Available codes are: {}'.format(
                                    rule_code, rulz.keys()))
Пример #3
0
 def _validate_config(cls, config):
     """
     Helper method for preventing config errors
     """
     if not config.get('DB_TYPE'):
         raise ConfigErr('Please verify that the config specifies'
                         ' the DB_TYPE parameter.')