Validate that the configuration file exists and is readable.

    :param str config_path: The path to the configuration file for the aptly instance.

    :return: None
    :rtype: None
503034
def _validate_config(config_path):
    '''
    
    '''
    log.debug('Checking configuration file: %s', config_path)

    if not os.path.isfile(config_path):
        message = 'Unable to get configuration file: {}'.format(config_path)
        log.error(message)
        raise SaltInvocationError(message)
    log.debug('Found configuration file: %s', config_path)
960483
def load_config(self, config_path=None):
        """"""
        if config_path is None:
            config_path = self.config_path
        else:
            self.config_path = config_path

        config = ConfigParser.SafeConfigParser(self.DEFAULT_SUBSTITUTIONS,
                                               allow_no_value=True)
        # Avoid the configparser automatically lowercasing keys
        config.optionxform = str
        self.initialize_config(config)
        try:
            with open(config_path) as f:
                config.readfp(f)
        except (IOError, ConfigParser.Error):
            _log.exception("Ignoring config from %s due to error.", config_path)
            return False

        self.config = config
        self.reload_modules()
        return True
1171416
def parse(config_path):
    
    config_path = os.path.expanduser(config_path)

    # Read the configuration file
    config_file = ConfigParser.RawConfigParser()
    config_file.SECTCRE = re.compile(r"\[ *(?P<header>.*) *\]")
    config_file.optionxform = lambda option: option
    config_file.read(config_path)

    #
    # Handle [global]
    #
    if 'global' in config_file.sections():
        global_config = __parse_options(
            config_file,
            'global',
            [
                {
                    'key': 'aws_access_key_id',
                    'option': 'aws-access-key-id',
                    'required': False,
                    'type': 'str'
                },
                {
                    'key': 'aws_secret_access_key',
                    'option': 'aws-secret-access-key-id',
                    'required': False,
                    'type': 'str'
                },
                {
                    'key': 'region',
                    'option': 'region',
                    'required': False,
                    'type': 'str'
                },
                {
                    'key': 'check_interval',
                    'option': 'check-interval',
                    'required': False,
                    'type': 'int'
                },
                {
                    'key': 'circuit_breaker_url',
                    'option': 'circuit-breaker-url',
                    'required': False,
                    'type': 'str'
                },
                {
                    'key': 'circuit_breaker_timeout',
                    'option': 'circuit-breaker-timeout',
                    'required': False,
                    'type': 'float'
                },
            ])

    #
    # Handle [logging]
    #
    if 'logging' in config_file.sections():
        logging_config = __parse_options(
            config_file,
            'logging',
            [
                {
                    'key': 'log_level',
                    'option': 'log-level',
                    'required': False,
                    'type': 'str'
                },
                {
                    'key': 'log_file',
                    'option': 'log-file',
                    'required': False,
                    'type': 'str'
                },
                {
                    'key': 'log_config_file',
                    'option': 'log-config-file',
                    'required': False,
                    'type': 'str'
                }
            ])

    if 'default_options' in config_file.sections():
        # nothing is required in defaults, so we set required to False
        default_config_options = deepcopy(TABLE_CONFIG_OPTIONS)
        for item in default_config_options:
            item['required'] = False
        default_options = __parse_options(
            config_file, 'default_options', default_config_options)
        # if we've got a default set required to be false for table parsing
        for item in TABLE_CONFIG_OPTIONS:
            if item['key'] in default_options:
                item['required'] = False
    else:
        default_options = {}

    #
    # Handle [table: ]
    #
    table_config = {'tables': ordereddict()}

    # Find the first table definition
    found_table = False
    for current_section in config_file.sections():
        if current_section.rsplit(':', 1)[0] != 'table':
            continue

        found_table = True
        current_table_name = current_section.rsplit(':', 1)[1].strip()
        table_config['tables'][current_table_name] = \
            dict(default_options.items() + __parse_options(
                config_file, current_section, TABLE_CONFIG_OPTIONS).items())

    if not found_table:
        print('Could not find a [table: <table_name>] section in {0}'.format(
            config_path))
        sys.exit(1)

    # Find gsi definitions - this allows gsi's to be defined before the table
    # definitions we don't worry about parsing everything twice here
    for current_section in config_file.sections():
        try:
            header1, gsi_key, header2, table_key = current_section.split(' ')
        except ValueError:
            continue

        if header1 != 'gsi:':
            continue

        if table_key not in table_config['tables']:
            print('No table configuration matching {0} found.'.format(
                table_key))
            sys.exit(1)

        if 'gsis' not in table_config['tables'][table_key]:
            table_config['tables'][table_key]['gsis'] = {}

        table_config['tables'][table_key]['gsis'][gsi_key] = \
            ordereddict(default_options.items() + __parse_options(
                config_file, current_section, TABLE_CONFIG_OPTIONS).items())

    return ordereddict(
        global_config.items() +
        logging_config.items() +
        table_config.items())
1206367
def _verify_config_dict(self, valid, config, dev_os, key_path=None):
        '''
        
        '''
        if not key_path:
            key_path = []
        for key, value in valid.items():
            self._verify_config_key(key, value, valid, config, dev_os, key_path)
1328396
def _load(self, file_path: Text) -> None:
        

        # noinspection PyUnresolvedReferences
        module_ = types.ModuleType('settings')
        module_.__file__ = file_path

        try:
            with open(file_path, encoding='utf-8') as f:
                exec(compile(f.read(), file_path, 'exec'), module_.__dict__)
        except IOError as e:
            e.strerror = 'Unable to load configuration file ({})'\
                .format(e.strerror)
            raise

        for key in dir(module_):
            if CONFIG_ATTR.match(key):
                self[key] = getattr(module_, key)
270535
def _check_config(self):
        
        current_path = os.path.relpath(os.getcwd())

        accepted_files = ["orator.yml", "orator.py"]
        for accepted_file in accepted_files:
            config_file = os.path.join(current_path, accepted_file)
            if os.path.exists(config_file):
                if self._handle_config(config_file):
                    return True

        return False
468694
def _isConfigFile(self,filename):
        """"""
        ext=os.path.splitext(filename)[1].lower()
        if filename in self.FB_CONFIG_FILES:
            return True
        elif ext in self.FB_META_EXTENSIONS:
            return True
        return False
759499
def read_config(path=None, final=False):
    """"""
    try:
        with open(config_path(path, final=final), 'r') as configfile:
            return yaml.safe_load(configfile) or {}
    except FileNotFoundError:
        return {}
20184
def check_web_config(config_fname):
    '''
        
    '''
    print("Looking for config file at {0} ...".format(config_fname))
    config = RawConfigParser()
    try:
        config.readfp(open(config_fname))
        return config
    except IOError:
        print("ERROR: Seems like the config file does not exist. Please call 'opensubmit-web configcreate' first, or specify a location with the '-c' option.")
        return None
437840
def run_license_checker(config_path):
    # type: (str) -> None
    
    whitelist_licenses = _get_whitelist_licenses(config_path)
    table = PrintTable(ROW_HEADERS)

    warnings = []

    for pkg in _get_packages():
        allowed = pkg.license in whitelist_licenses
        table.add_row((pkg.name, pkg.version, pkg.license, str(allowed)))

        if not allowed:
            warnings.append(pkg)

    print(table)

    print('{} RESTRICTED LICENSES DETECTED'.format(len(warnings)))
474452
def validate_bot_config(config_bundle) -> None:
    
    if not config_bundle.name:
        bot_config = os.path.join(config_bundle.config_directory, config_bundle.config_file_name or '')
        raise AttributeError(f"Bot config {bot_config} has no name configured!")

    # This will raise an exception if we can't find the looks config, or if it's malformed
    config_bundle.get_looks_config()
823274
def _validate_config(self, config):
        
        required_keys = [
            self.KEY_IDP_CONFIG,
            self.KEY_ENDPOINTS,
        ]

        if not config:
            raise ValueError("No configuration given")

        for key in required_keys:
            try:
                _val = config[key]
            except KeyError as e:
                raise ValueError("Missing configuration key: %s" % key) from e
329210
def load(self, path):
        
        with open(path) as f:
            self.config = full_load(f)
            if self.config is None:
                sys.stderr.write("Warning: config file is empty!\n")
                self.config = {}
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
232092
def modify_config(path):
    
    if isinstance(path, str):
        path = Path(path)
    config = _read_pkg_ini(path)
    _validate_config(config, path)

    # don't catch exception, we won't write the new config.
    yield config

    _validate_config(config, path)
    with path.open('w') as f:
        config.write(f)
1254266
def check_file_path(self, path):
        
        if os.path.exists(path) is not True:
            msg = "File Not Found {}".format(path)
            raise OSError(msg)
1240325
def validate(path)
      file_contents = open(path).read
      preferences = file_contents.empty? ? {} : YAML.load(file_contents).to_hash

      unless preferences[TEMPLATES_KEY]
        puts "You can't run *generamba gen* without any templates installed. Add their declarations to a Rambafile and run *generamba template install*.".red
        exit
      end
    end