Example #1
0
        raise InvalidManifestError(
            'Invalid files regex at {0}: {1}'.format(
                hook_config['id'],
                hook_config['files'],
            )
        )


def additional_manifest_check(obj):
    for hook_config in obj:
        validate_languages(hook_config)
        validate_files(hook_config)


load_manifest = get_validator(
    MANIFEST_JSON_SCHEMA,
    InvalidManifestError,
    additional_manifest_check,
)


run = get_run_function(
    'Manifest filenames.',
    load_manifest,
    InvalidManifestError,
)


if __name__ == '__main__':
    exit(run())

def try_regex(repo, hook, value, field_name):
    if not is_regex_valid(value):
        raise InvalidConfigError(
            'Invalid {0} regex at {1}, {2}: {3}'.format(
                field_name, repo, hook, value,
            )
        )


def validate_config_extra(config):
    for repo in config:
        for hook in repo['hooks']:
            try_regex(repo, hook['id'], hook.get('files', ''), 'files')
            try_regex(repo, hook['id'], hook['exclude'], 'exclude')


load_config = get_validator(
    CONFIG_JSON_SCHEMA,
    InvalidConfigError,
    additional_validation_strategy=validate_config_extra,
)


run = get_run_function('Config filenames.', load_config, InvalidConfigError)


if __name__ == '__main__':
    exit(run())
Example #3
0
    if not is_regex_valid(hook_config.get('exclude', '')):
        raise InvalidManifestError(
            'Invalid exclude regex at {0}: {1}'.format(
                hook_config['id'], hook_config['exclude'],
            )
        )


def additional_manifest_check(obj):
    for hook_config in obj:
        validate_languages(hook_config)
        validate_files(hook_config)


load_manifest = get_validator(
    MANIFEST_JSON_SCHEMA,
    InvalidManifestError,
    additional_manifest_check,
)


run = get_run_function(
    'Manifest filenames.',
    load_manifest,
    InvalidManifestError,
)


if __name__ == '__main__':
    exit(run())
Example #4
0
}


def try_regex(repo, hook, value, field_name):
    if not is_regex_valid(value):
        raise InvalidConfigError('Invalid {0} regex at {1}, {2}: {3}'.format(
            field_name,
            repo,
            hook,
            value,
        ))


def validate_config_extra(config):
    for repo in config:
        for hook in repo['hooks']:
            try_regex(repo, hook['id'], hook.get('files', ''), 'files')
            try_regex(repo, hook['id'], hook['exclude'], 'exclude')


load_config = get_validator(
    CONFIG_JSON_SCHEMA,
    InvalidConfigError,
    additional_validation_strategy=validate_config_extra,
)

run = get_run_function('Config filenames.', load_config, InvalidConfigError)

if __name__ == '__main__':
    exit(run())

def validate_languages(hook_config):
    if hook_config["language"] not in all_languages:
        raise InvalidManifestError(
            "Expected language {0} for {1} to be one of {2!r}".format(
                hook_config["id"], hook_config["language"], all_languages
            )
        )


def validate_files(hook_config):
    if not is_regex_valid(hook_config["files"]):
        raise InvalidManifestError("Invalid files regex at {0}: {1}".format(hook_config["id"], hook_config["files"]))


def additional_manifest_check(obj):
    for hook_config in obj:
        validate_languages(hook_config)
        validate_files(hook_config)


load_manifest = get_validator(MANIFEST_JSON_SCHEMA, InvalidManifestError, additional_manifest_check)


run = get_run_function("Manifest filenames.", load_manifest, InvalidManifestError)


if __name__ == "__main__":
    exit(run())