How to use the cfgv.check_string function in cfgv

To help you get started, we’ve selected a few cfgv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github asottile / git-code-debt / git_code_debt / generate_config.py View on Github external
from __future__ import absolute_import
from __future__ import unicode_literals

import collections
import re

import cfgv


DEFAULT_GENERATE_CONFIG_FILENAME = 'generate_config.yaml'
SCHEMA = cfgv.Map(
    'Config', 'repo',

    cfgv.Required('repo', cfgv.check_string),
    cfgv.Required('database', cfgv.check_string),
    cfgv.Optional('skip_default_metrics', cfgv.check_bool, False),
    cfgv.Optional(
        'metric_package_names', cfgv.check_array(cfgv.check_string), [],
    ),
    cfgv.Optional('exclude', cfgv.check_regex, '^$'),
)


class GenerateOptions(
        collections.namedtuple(
            'GenerateOptions',
            (
                'skip_default_metrics',
                'metric_package_names',
                'repo',
github asottile / git-code-debt / git_code_debt / generate_config.py View on Github external
import collections
import re

import cfgv


DEFAULT_GENERATE_CONFIG_FILENAME = 'generate_config.yaml'
SCHEMA = cfgv.Map(
    'Config', 'repo',

    cfgv.Required('repo', cfgv.check_string),
    cfgv.Required('database', cfgv.check_string),
    cfgv.Optional('skip_default_metrics', cfgv.check_bool, False),
    cfgv.Optional(
        'metric_package_names', cfgv.check_array(cfgv.check_string), [],
    ),
    cfgv.Optional('exclude', cfgv.check_regex, '^$'),
)


class GenerateOptions(
        collections.namedtuple(
            'GenerateOptions',
            (
                'skip_default_metrics',
                'metric_package_names',
                'repo',
                'database',
                'exclude',
            ),
        ),
github pre-commit / pre-commit / pre_commit / clientlib.py View on Github external
cfgv.Optional('alias', cfgv.check_string, ''),

    cfgv.Optional('files', check_string_regex, ''),
    cfgv.Optional('exclude', check_string_regex, '^$'),
    cfgv.Optional('types', cfgv.check_array(check_type_tag), ['file']),
    cfgv.Optional('exclude_types', cfgv.check_array(check_type_tag), []),

    cfgv.Optional(
        'additional_dependencies', cfgv.check_array(cfgv.check_string), [],
    ),
    cfgv.Optional('args', cfgv.check_array(cfgv.check_string), []),
    cfgv.Optional('always_run', cfgv.check_bool, False),
    cfgv.Optional('pass_filenames', cfgv.check_bool, True),
    cfgv.Optional('description', cfgv.check_string, ''),
    cfgv.Optional('language_version', cfgv.check_string, C.DEFAULT),
    cfgv.Optional('log_file', cfgv.check_string, ''),
    cfgv.Optional('minimum_pre_commit_version', cfgv.check_string, '0'),
    cfgv.Optional('require_serial', cfgv.check_bool, False),
    cfgv.Optional('stages', cfgv.check_array(cfgv.check_one_of(C.STAGES)), []),
    cfgv.Optional('verbose', cfgv.check_bool, False),
)
MANIFEST_SCHEMA = cfgv.Array(MANIFEST_HOOK_DICT)


class InvalidManifestError(FatalError):
    pass


load_manifest = functools.partial(
    cfgv.load_from_filename,
    schema=MANIFEST_SCHEMA,
    load_strategy=ordered_load,
github pre-commit / pre-commit / pre_commit / clientlib.py View on Github external
def _cond(key):
        return cfgv.Conditional(
            key, cfgv.check_string,
            condition_key='repo',
            condition_value=cfgv.NotIn(LOCAL, META),
            ensure_absent=True,
        )