def __init__(self, config_file=None):
        '''Attempt to initialize a config dictionary from a yaml file.

        Error out if loading the yaml file fails for any reason.
        :param config_file: The Bandit yaml config file

        :raises bandit.utils.ConfigError: If the config is invalid or
            unreadable.
        '''
        self.config_file = config_file
        self._config = {}

        if config_file:
            try:
                f = open(config_file, 'r')
            except __HOLE__:
                raise utils.ConfigError("Could not read config file.",
                                        config_file)

            try:
                self._config = yaml.safe_load(f)
                self.validate(config_file)
            except yaml.YAMLError:
                raise utils.ConfigError("Error parsing file.", config_file)

            # valid config must be a dict
            if not isinstance(self._config, dict):
                raise utils.ConfigError("Error parsing file.", config_file)

            self.convert_legacy_config()

        else:
            # use sane defaults
            self._config['plugin_name_pattern'] = '*.py'
            self._config['include'] = ['*.py', '*.pyw']

        self._init_settings()
dataset/ETHPy150Open openstack/bandit/bandit/core/config.py/BanditConfig.__init__