Read the Ceph config file and return the value of mon_initial_members
    Optionally, a NeedHostError can be raised if the value is None.
556725
def get_mon_initial_members(args, error_on_empty=False, _cfg=None):
    
    if _cfg:
        cfg = _cfg
    else:
        cfg = conf.ceph.load(args)
    mon_initial_members = cfg.safe_get('global', 'mon_initial_members')
    if not mon_initial_members:
        if error_on_empty:
            raise exc.NeedHostError(
                'could not find `mon initial members` defined in ceph.conf'
            )
    else:
        mon_initial_members = re.split(r'[,\s]+', mon_initial_members)
    return mon_initial_members
571914
def read_value_from_path(value):
    
    if value.startswith('file://'):
        path = value.split('file://', 1)[1]
        config_directory = get_config_directory()
        relative_path = os.path.join(config_directory, path)
        with open(relative_path) as read_file:
            value = read_file.read()
    return value
463783
def fromConfigFile(filename = DEFAULT_CONFIG_FILE):
    
    parser = SafeConfigParser()
    section = 'fenixedu'
    parser.read(filename)

    client_id = parser.get(section, 'client_id')
    redirect_uri = parser.get(section, 'redirect_uri')
    client_secret = parser.get(section, 'client_secret')

    base_url = parser.get(section, 'base_url')
    api_endpoint = parser.get(section, 'api_endpoint')
    api_version = parser.get(section, 'api_version')

    return FenixEduConfiguration(client_id = client_id,
                                  redirect_uri = redirect_uri,
                                  client_secret = client_secret,
                                  base_url = base_url,
                                  api_endpoint = api_endpoint,
                                  api_version = api_version)
497035
def get_config_value_from_file(key, config_path=None, default=None):
    
    config = _get_config_dict_from_file(config_path)
    if key not in config:
        return default
    return config[key]
333390
def _load_cwr_defaults(self):
        
        if self._cwr_defaults is None:
            self._cwr_defaults = self._reader.read_yaml_file(
                self._file_defaults)

        return self._cwr_defaults
925493
def read_config(self):
        
        _config = self.config["dikicli"]
        # TODO: what if file doesn't exist?
        if self.config_file.is_file():
            logger.debug("Reading config file: %s", self.config_file.as_posix())
            with open(self.config_file, mode="r") as f:
                self.config.read_file(f)

            # DIKI_DATA_DIR should always take precedence if it's set
            if "DIKI_DATA_DIR" in os.environ:
                _config["data dir"] = DATA_DIR.as_posix()

            w = _config.get("linewrap")
            try:
                w = int(w)
                if w < 0:
                    raise ValueError()
            except ValueError:
                logger.warning("Config: Invalid linewrap value. Using default.")
                _config["linewrap"] = self.default_config["linewrap"]

            c = _config.get("colors")
            if c.lower() not in ["yes", "no", "true", "false"]:
                logger.warning("Config: Invalid colors value. Using default.")
                _config["colors"] = self.default_config["colors"]
348992
def read(config_file, configspec, server_mode=False, default_section='default_settings', list_values=True):
    '''
    
    '''
#    configspec = ConfigObj(path.join(path.abspath(path.dirname(__file__)), configspec),
#                           encoding='UTF8',
#                           interpolation='Template',
#                           list_values=False,
#                           _inspec=True)
    config = ConfigObj(config_file,
                       configspec=path.join(path.abspath(path.dirname(__file__)),
                                            configspec),
                                            list_values=list_values)
    validation = config.validate(validate.Validator(), preserve_errors=True)

    if validation == True:
        config = dict(config)
        for section in config:
            if section != default_section:
                if server_mode: # When it's a servers config file, retrieve the correct fqdn
                    config[section]['availability'] = True
                    if config[section]['custom_fqdn'] == None:
                        config[section]['custom_fqdn'] = socket.getfqdn()
                for option in config[section]:  # retrieve default configuration for missing values
                    if config[section][option] == None:
                        config[section][option] = config[default_section][option]

        del(config[default_section])

        return config
    else:
        raise ConfiguratorException(config_file, validation)
576881
def read_config(contents):
    
    file_obj = io.StringIO(contents)
    config = six.moves.configparser.ConfigParser()
    config.readfp(file_obj)
    return config
157006
def load_config(cls, configfile="logging.yaml"):
        
        configfile = getenv(cls.CONFIGFILE_ENV_KEY, configfile)
        if isfile(configfile):
            with open(configfile, "r") as cf:
                # noinspection PyBroadException
                try:
                    dictConfig(load(cf))
                except ValueError:
                    debug("Learn to config foooo! Improper config at %s", configfile)
                except Exception:
                    exception("Something went wrong while reading %s.", configfile)
        else:
            raise ValueError("Invalid configfile specified: {}".format(configfile))
1237662
function readConfig() {
  let options = {}
  let cFile = ''

  if (program.config) {
    cFile = path.resolve(cwd, program.config)
    if (fs.existsSync(cFile)) {
      Object.assign(config, require(cFile))
    } else {
      console.warn(`Cannot find configuration file ${program.config}`)
      process.exit()
    }
  } else {
    cFile = path.resolve(cwd, 'deploy.js')
  }

  if (fs.existsSync(cFile)) {
    options = require(cFile)
  }

  ;['server', 'ignore'].forEach(function(name) {
    if (typeof program[name] !== 'undefined') {
      options[name] = program[name]
    }
  })

  if (program.args[0]) {
    options.workspace = path.resolve(cwd, program.args[0])
  }

  if (program.args[1]) {
    options.deployTo = program.args[1]
  }

  return options
}
818086
def load_conf(cnf) # :nodoc:

      if cnf.nil? or cnf.empty? 
        raise RepoAccessError, 'No config file provided!'
      elsif cnf and cnf.class == String and File.exists? cnf
        @svn_repo_config_file = cnf
        cnf = IO.read(cnf)
      end

      begin
        YAML::load(cnf)
       rescue Exception => e
        raise RepoAccessError, e.message
      end
    end
1229873
def get_config(path=os.getcwd()):
    """"""
    config = default
    tries = 0
    current_dir = path
    while current_dir and tries < MAX_CONFIG_SEARCH_DEPTH:
        potential_path = os.path.join(current_dir, ".fonduer-config.yaml")
        if os.path.exists(potential_path):
            with open(potential_path, "r") as f:
                config = _merge(config, yaml.safe_load(f))
            logger.debug(f"Loading Fonduer config from {potential_path}.")
            break

        new_dir = os.path.split(current_dir)[0]
        if current_dir == new_dir:
            logger.debug("Unable to find config file. Using defaults.")
            break
        current_dir = new_dir
        tries += 1

    return config
577908
def read_configuration_file(pPath = '.kuniri.yml')
      if !(File.exist?(pPath))
        set_default_configuration
      else
        safeInfo = SafeYAML.load(File.read(pPath))
        # SafeYAML add collon (':') in the begin of each key. We handle it here
        @configurationInfo = safeInfo.map do |key, value|
          [key.tr(':', '').to_sym, value]
        end.to_h
        verify_syntax
      end

      return @configurationInfo
    end
24149
def load_config_file(config_file_path, config_file):
    

    if config_file_path.lower().endswith(".yaml"):
        return yaml.load(config_file)

    if any(config_file_path.lower().endswith(extension) for extension in INI_FILE_EXTENSIONS):
        return load_config_from_ini_file(config_file)

    # At this point we have to guess the format of the configuration file.
    try:
        return yaml.load(config_file)
    except yaml.YAMLError:
        pass

    try:
        return load_config_from_ini_file(config_file)
    except:
        pass

    raise Exception("Could not load configuration file!")
1078270
def read(self, config_dir=None, config_name=None, clear=False):
        

# TODO should probably allow config_dir to be a list as well
        # get name of config directory
        if not config_dir:
            config_dir = self._defaults.get('config_dir', None)
        if not config_dir:
            raise KeyError('config_dir not set')

        # get name of config file
        if not config_name:
            config_name = self._defaults.get('config_name', None)
        if not config_name:
            raise KeyError('config_name not set')

        conf_path = os.path.expanduser(config_dir)
        if not os.path.exists(conf_path):
            raise IOError("config dir not found at %s" % (conf_path,))

        config = munge.load_datafile(config_name, conf_path, default=None)

        if not config:
            raise IOError("config file not found in %s" % (conf_path,))

        if clear:
            self.clear()

        munge.util.recursive_update(self.data, config)
        self._meta_config_dir = conf_path
        return self
790590
def choose_init(module):
    
    # Upstart checks first because when installing ceph, the
    # `/lib/systemd/system/ceph.target` file may be created, fooling this
    # detection mechanism.
    if is_upstart(module.conn):
        return 'upstart'

    if is_systemd(module.conn) or module.conn.remote_module.path_exists(
            "/lib/systemd/system/ceph.target"):
        return 'systemd'

    return 'sysvinit'
44519
def match_member_id(self, member_conf, current_member_confs):
        
        if current_member_confs is None:
            return None

        for curr_mem_conf in current_member_confs:
            if is_same_address(member_conf['host'], curr_mem_conf['host']):
                return curr_mem_conf['_id']

        return None