basic checks that the configuration file is valid
761903
def check_config(config):
    ""
    shortnames = [count['shortname'] for count in config['count']]
    if len(shortnames) != len(set(shortnames)):
        logger.error("error: duplicate `shortname' in count configuration.")
        return False
    return True
32737
protected function verifyConfiguration()
    {
        if (isset($this->options->filtered['configuration']) && !file_exists($this->options->filtered['configuration']->getPath())) {
            $this->printer->println(sprintf('Could not read "%s".', $this->options->filtered['configuration']));
            exit(1);
        }
    }
1308423
def checkConfig():
    """"""
    config_file_dir = os.path.join(cwd, "config.py")
    if os.path.exists(config_file_dir):
        print("Making a backup of your config file!")
        config_file_dir2 = os.path.join(cwd, "config.py.oldbak")
        copyfile(config_file_dir, config_file_dir2)
709314
def check_config(self, config):
        
        validation = ""
        required = ["name", "currency", "IBAN", "BIC"]

        for config_item in required:
            if config_item not in config:
                validation += config_item.upper() + "_MISSING "

        if not validation:
            return True
        else:
            raise Exception("Config file did not validate. " + validation)
687870
def format_check(settings):
    

    valid_keys = ['logs_folder', 'log_file', 'log_console', 'log_name',
                  'log_filename', 'keep_osm_tags']

    for key in list(settings.keys()):
        assert key in valid_keys, \
            ('{} not found in list of valid configuation keys').format(key)
        assert isinstance(key, str), ('{} must be a string').format(key)
        if key == 'keep_osm_tags':
            assert isinstance(settings[key], list), \
                ('{} must be a list').format(key)
            for value in settings[key]:
                assert all(isinstance(element, str) for element in value), \
                    'all elements must be a string'
        if key == 'log_file' or key == 'log_console':
            assert isinstance(settings[key], bool), \
                ('{} must be boolean').format(key)
1303670
def _is_valid_file(self, path):
        """"""
        return isinstance(path, basestring) and os.path.isfile(path)
1361243
def validate(config):
    '''
    
    '''
    # Configuration for adb beacon should be a dictionary with states array
    if not isinstance(config, list):
        log.info('Configuration for adb beacon must be a list.')
        return False, ('Configuration for adb beacon must be a list.')

    _config = {}
    list(map(_config.update, config))

    if 'states' not in _config:
        log.info('Configuration for adb beacon must include a states array.')
        return False, ('Configuration for adb beacon must include a states array.')
    else:
        if not isinstance(_config['states'], list):
            log.info('Configuration for adb beacon must include a states array.')
            return False, ('Configuration for adb beacon must include a states array.')
        else:
            states = ['offline', 'bootloader', 'device', 'host',
                      'recovery', 'no permissions',
                      'sideload', 'unauthorized', 'unknown', 'missing']
            if any(s not in states for s in _config['states']):
                log.info('Need a one of the following adb '
                         'states: %s', ', '.join(states))
                return False, ('Need a one of the following adb '
                               'states: {0}'.format(', '.join(states)))
    return True, 'Valid beacon configuration'
335835
def validate_config(cls, config):
        
        if "config_file" not in config:
            raise ValueError("No config file path given")
        if "socket_file" not in config:
            raise ValueError("No control socket path given")
        if "pid_file" not in config:
            raise ValueError("No PID file path given")
        if "stats" in config and "port" not in config["stats"]:
            raise ValueError("Stats interface defined, but no port given")
        if "proxies" in config:
            cls.validate_proxies_config(config["proxies"])

        return config
1043804
def validate_file_permissions(config):
    """"""
    files = config.get('files', {})
    for file_name, options in files.items():
        for key in options.keys():
            if key not in ["owner", "group", "mode"]:
                raise RuntimeError(
                    "Invalid ownership configuration: {}".format(key))
        mode = options.get('mode', config.get('permissions', '600'))
        optional = options.get('optional', config.get('optional', 'False'))
        if '*' in file_name:
            for file in glob.glob(file_name):
                if file not in files.keys():
                    if os.path.isfile(file):
                        _validate_file_mode(mode, file, optional)
        else:
            if os.path.isfile(file_name):
                _validate_file_mode(mode, file_name, optional)
1150540
def _check_file(parameters):
    """"""
    (filename, args) = parameters

    if filename == '-':
        contents = sys.stdin.read()
    else:
        with contextlib.closing(
            docutils.io.FileInput(source_path=filename)
        ) as input_file:
            contents = input_file.read()

    args = load_configuration_from_file(
        os.path.dirname(os.path.realpath(filename)), args)

    ignore_directives_and_roles(args.ignore_directives, args.ignore_roles)

    for substitution in args.ignore_substitutions:
        contents = contents.replace('|{}|'.format(substitution), 'None')

    ignore = {
        'languages': args.ignore_language,
        'messages': args.ignore_messages,
    }
    all_errors = []
    for error in check(contents,
                       filename=filename,
                       report_level=args.report,
                       ignore=ignore,
                       debug=args.debug):
        all_errors.append(error)
    return (filename, all_errors)
443285
function checkConfiguration(conf) {
    let failedChecks = 0;

    for (const path of Object.keys(CHECKS)) {
        // @todo avoid try..catch
        try {
            checkProperty(path, get(conf, path), CHECKS[path]);
        } catch (error) {
            LusterConfigurationError.ensureError(error).log();
            ++failedChecks;
        }
    }

    return failedChecks;
}
1316221
def _valid_file(self, base, name):
        """"""

        valid = False
        fullpath = os.path.join(base, name)
        if self.file_check is not None and self.compare_file(fullpath[self._base_len:] if self.file_pathname else name):
            valid = True
        if valid and (not self.show_hidden and util.is_hidden(fullpath)):
            valid = False
        return self.on_validate_file(base, name) if valid else valid
243945
def validate_config_file(cls, config_filepath):
        
        is_file = os.path.isfile(config_filepath)
        if not is_file and os.path.isabs(config_filepath):
            raise IOError('File path %s is not a valid yml, ini or cfg file or does not exist' % config_filepath)

        elif is_file:
            if os.path.getsize(config_filepath) == 0:
                raise IOError('File %s is empty' % config_filepath)

        with open(config_filepath, 'r') as f:
            if yaml.load(f) is None:
                raise IOError('No YAML config was found in file %s' % config_filepath)
853541
def _check_config_file(self, usr):
        '''  '''
        package_config_file = path.join(path.dirname(__file__), 'config')
        user_config_file = path.join(usr, 'config')

        ''' restore config from bck file '''
        if path.exists(user_config_file + '.restore'):
            try:
                copyfile(user_config_file + '.restore', user_config_file)
                remove(self.user_config_file + '.restore')
            except:
                pass

        ''' Copy package config into user dir '''
        if not path.exists(user_config_file):
            copyfile(package_config_file, user_config_file)
871130
def is_valid_py_file(path):
    '''
    
    '''
    import os

    is_valid = False
    if os.path.isfile(path) and not os.path.splitext(path)[1] == '.pyx':
        try:
            with open(path, 'rb') as f:
                compile(f.read(), path, 'exec')
                is_valid = True
        except:
            pass
    return is_valid
1019351
def validate(config):
    """"""
    with open(config) as fh:
        content = fh.read()

    try:
        data = yaml.safe_load(content)
    except Exception:
        log.error("config file: %s is not valid yaml", config)
        raise

    try:
        jsonschema.validate(data, CONFIG_SCHEMA)
    except Exception:
        log.error("config file: %s is not valid", config)
        raise

    log.info("config file valid, accounts:%d", len(data['accounts']))
    return data
41588
def is_valid_file(parser, arg):
    """"""
    arg = os.path.abspath(arg)
    if not os.path.exists(arg):
        parser.error("The file %s does not exist!" % arg)
    else:
        return arg