Read the ini-style topology file using ConfigObj

        :return config: Topology parsed by :py:mod:`ConfigObj`
        :rtype: ConfigObj
482932
def read_topology(self):
        
        configspec = resource_stream(__name__, 'configspec')
        try:
            handle = open(self._topology)
            handle.close()
            try:
                config = ConfigObj(self._topology,
                                   configspec=configspec,
                                   raise_errors=True,
                                   list_values=False,
                                   encoding='utf-8')
            except SyntaxError:
                logging.error('Error loading .net file')
                sys.exit(1)
        except IOError:
            logging.error('Cannot open topology file')
            sys.exit(1)

        vtor = Validator()
        res = config.validate(vtor, preserve_errors=True)
        if res:
            logging.debug('Validation passed')
        elif not res:
            for entry in flatten_errors(config, res):
                # each entry is a tuple
                (section_list, key, error) = entry
                if key is not None:
                    section_list.append(key)
                else:
                    section_list.append('[missing section]')
                section_string = ', '.join(section_list)

                if error is False:
                    error = 'Missing value or section'
                print(section_string, ' = ', error)
                input('Press ENTER to continue')
                sys.exit(1)

        configspec.close()
        return config
1292045
def read_config(config):
    
    for line in config.splitlines():
        line = line.lstrip()
        if line and not line.startswith("#"):
            return line
    return ""
1299854
def _read_config(config_location):
    
    global LOGGING_CONFIG
    with open(config_location, "r") as config_loc:
        cfg_file = json.load(config_loc)
        if "logging" in cfg_file:
            log_dict = cfg_file.get("logging")
            with open(os.path.abspath(os.path.join(__file__,
                                                   os.path.pardir,
                                                   'logging_schema.json'))) as schema_file:
                logging_schema = json.load(schema_file)
                jsonschema.validate(log_dict, logging_schema)
                merged = jsonmerge.merge(LOGGING_CONFIG, log_dict)
                LOGGING_CONFIG = merged
68825
def load_topology_config(self):
        """"""
        config_path = os.path.join(
            self.kafka_topology_path,
            '{id}.yaml'.format(id=self.cluster_type),
        )
        self.log.debug("Loading configuration from %s", config_path)
        if os.path.isfile(config_path):
            topology_config = load_yaml_config(config_path)
        else:
            raise MissingConfigurationError(
                "Topology configuration {0} for cluster {1} "
                "does not exist".format(
                    config_path,
                    self.cluster_type,
                )
            )
        self.log.debug("Topology configuration %s", topology_config)
        try:
            self.clusters = topology_config['clusters']
        except KeyError:
            self.log.exception("Invalid topology file")
            raise InvalidConfigurationError("Invalid topology file {0}".format(
                config_path))
        if 'local_config' in topology_config:
            self.local_config = topology_config['local_config']
731757
def get_conf_file(self):
        
        for conf_file in [self.collection_rules_file, self.fallback_file]:
            logger.debug("trying to read conf from: " + conf_file)
            conf = self.try_disk(conf_file, self.gpg)

            if not conf:
                continue

            version = conf.get('version', None)
            if version is None:
                raise ValueError("ERROR: Could not find version in json")

            conf['file'] = conf_file
            logger.debug("Success reading config")
            logger.debug(json.dumps(conf))
            return conf

        raise ValueError("ERROR: Unable to download conf or read it from disk!")
965222
def get_config_dict(self):
        
        return OrderedDict((prop, getattr(self, prop)) for prop in self._instance.CONFIG_PARAMS)
1009433
def get_ini(self, incl_unset=False):
        

        configp = configparser.ConfigParser(allow_no_value=True)
        configp.read_dict(self._config)
        with StringIO() as config_ini:
            if self._parser:
                self._parser.set_defaults(
                    **self.get_section(self.root_section)
                )
                argparse_ini = argparse_to_ini(
                    parser=self._parser, incl_unset=incl_unset
                )
                return argparse_ini
            else:
                configp.write(config_ini)
                return config_ini.getvalue()
290674
def get_snapshots(topology):
    
    snapshots = []
    snap_dir = os.path.join(topology_dirname(topology), 'snapshots')
    if os.path.exists(snap_dir):
        snaps = os.listdir(snap_dir)
        for directory in snaps:
            snap_top = os.path.join(snap_dir, directory, 'topology.net')
            if os.path.exists(snap_top):
                snapshots.append({'file': snap_top,
                                  'snapshot': True})
    return snapshots
94129
def read_config(self):
        
        try:
            with open(self.config_file, 'r') as f:
                self.config = json.loads(f.read())
                f.close()
        except IOError:
            return False
        return True
1279553
def load_ini(self):
        
        if not self.config_file:
            return

        # Load INI file
        ini_file = ConfigParser.SafeConfigParser()
        if not ini_file.read(self.config_file):
            raise ConfigParser.ParsingError("Global configuration file %r not found!" % (
                self.config_file,
            ))

        """
        # Make sure there's our global settings section
        if not ini_file.has_section(self.SECTION):
            raise ConfigParser.ParsingError("%r needs to have a [%s] section!" % (
                self.config_file, self.SECTION,
            ))

        # Get the given values
        for key, val in ini_file.items(self.SECTION):
            # Ensure that all names are known (to prevent uncaught typos)
            if key not in self.KEYS:
                raise ConfigParser.ParsingError("%r has an unknown key %s in the [%s] section!" % (
                    self.config_file, key, self.SECTION,
                ))

            # Do some shell-like path expansion
            val = os.path.expanduser(os.path.expandvars(val))

            # Set as attribute for easy access
            setattr(self, key, val)
        """

        self._validate()
502764
def read_config(config_path_or_dict=None):
    
    config = None

    if isinstance(config_path_or_dict, dict):
        config = Config(config_path_or_dict)

    if isinstance(config_path_or_dict, string_types):
        if os.path.isabs(config_path_or_dict):
            config_path = config_path_or_dict
        else:
            config_path = os.path.join(
                os.getcwd(),
                os.path.normpath(config_path_or_dict)
            )
    else:
        config_path = os.path.join(
            os.getcwd(),
            DEFAULT_CONFIG_PATH
        )

    if os.path.exists(config_path):
        with open(config_path, 'r') as f:
            data = json.load(f)
            config = Config(data)

    if config is None:
        raise ConfigNotFound()
    else:
        config.validate()

        return config
808633
def read_config_file(path):
    """"""
    try:
        with open(path, 'r') as f:
            return json.load(f, object_pairs_hook=OrderedDict)
    except IOError as ex:
        if ex != errno.ENOENT:
            raise
    return {}
1059270
def get_config():
  """"""
  # TODO(hanuszczak): See comment in `setup.py` for `grr-response-proto`.
  ini_path = os.path.join(THIS_DIRECTORY, "version.ini")
  if not os.path.exists(ini_path):
    ini_path = os.path.join(THIS_DIRECTORY, "../../version.ini")
    if not os.path.exists(ini_path):
      raise RuntimeError("Couldn't find version.ini")

  config = configparser.SafeConfigParser()
  config.read(ini_path)
  return config
697120
def ini2value(ini_content):
    
    from mo_future import ConfigParser, StringIO

    buff = StringIO(ini_content)
    config = ConfigParser()
    config._read(buff, "dummy")

    output = {}
    for section in config.sections():
        output[section]=s = {}
        for k, v in config.items(section):
            s[k]=v
    return wrap(output)
813692
def read_config(*args):
    '''
    
    '''

    ret = {}
    if _TRAFFICCTL:
        cmd = _traffic_ctl('config', 'get')
    else:
        cmd = _traffic_line('-r')

    try:
        for arg in args:
            log.debug('Querying: %s', arg)
            ret[arg] = _subprocess(cmd + [arg])
    except KeyError:
        pass

    return ret
102056
def conf_from_dict(conf_dict):
    '''
    
    '''
    conf = Config(filename=conf_dict.get('__file__', ''))

    for k, v in six.iteritems(conf_dict):
        if k.startswith('__'):
            continue
        elif inspect.ismodule(v):
            continue

        conf[k] = v
    return conf
757928
def _load_config_file(self):
        
        LOGGER.info('Loading configuration from %s', self._file_path)
        if self._file_path.endswith('json'):
            config = self._load_json_config()
        else:
            config = self._load_yaml_config()
        for key, value in [(k, v) for k, v in config.items()]:
            if key.title() != key:
                config[key.title()] = value
                del config[key]
        return flatdict.FlatDict(config)