Load a Kubernetes config from a Reader
344160
public static KubeConfig loadKubeConfig(Reader input) {
    Yaml yaml = new Yaml(new SafeConstructor());
    Object config = yaml.load(input);
    Map<String, Object> configMap = (Map<String, Object>) config;

    String currentContext = (String) configMap.get("current-context");
    ArrayList<Object> contexts = (ArrayList<Object>) configMap.get("contexts");
    ArrayList<Object> clusters = (ArrayList<Object>) configMap.get("clusters");
    ArrayList<Object> users = (ArrayList<Object>) configMap.get("users");
    Object preferences = configMap.get("preferences");

    KubeConfig kubeConfig = new KubeConfig(contexts, clusters, users);
    kubeConfig.setContext(currentContext);
    kubeConfig.setPreferences(preferences);

    return kubeConfig;
  }
218905
def load(self, config):
        """"""
        password_dict = {}

        if config is None:
            logger.warning("No configuration file available. Cannot load password list.")
        elif not config.has_section(self._section):
            logger.warning("No [%s] section in the configuration file. Cannot load password list." % self._section)
        else:
            logger.info("Start reading the [%s] section in the configuration file" % self._section)

            password_dict = dict(config.items(self._section))

            # Password list loaded
            logger.info("%s password(s) loaded from the configuration file" % len(password_dict))
            logger.debug("Password dictionary: %s" % password_dict)

        return password_dict
357710
def load_config_file(self, path, profile=None):
        """"""
        config_cls = self.get_config_reader()
        return config_cls.load_config(self, path, profile=profile)
377385
public static Config fromJSON(Reader reader) throws IOException {
        ConfigSupport support = new ConfigSupport();
        return support.fromJSON(reader, Config.class);
    }
163136
def load(klass):
        
        config = klass()
        for path in klass.CONF_PATHS:
            if os.path.exists(path):
                with open(path, 'r') as conf:
                    config.configure(yaml.safe_load(conf))
        return config
758336
def load_config(config_file):
    
    with open(config_file) as in_handle:
        config = yaml.safe_load(in_handle)
    config = _expand_paths(config)
    if 'resources' not in config:
        config['resources'] = {}
    # lowercase resource names, the preferred way to specify, for back-compatibility
    newr = {}
    for k, v in config["resources"].items():
        if k.lower() != k:
            newr[k.lower()] = v
    config["resources"].update(newr)
    return config
1176075
def _load_config(self):
        
        if not os.path.exists(self._path):
            sys.exit("Config path %s does not exist" % self._path)
        # create empty config object
        self._config_dict = {}
        # read file and marshal yaml
        with open(self._path, 'r') as f:
            self._raw = f.read()
            self._config_dict = yaml.load(self._raw)
784052
def _load(self):
        """"""
        for attr_name, config_prop in self._iter_config_props():
            found = False
            for loader in self._loaders:
                if loader.exists(config_prop.property_key):
                    raw_value = loader.get(config_prop.property_key)
                    converted_value = config_prop.load(raw_value)

                    self._set_instance_prop(attr_name, config_prop, converted_value)
                    found = True
                    break

            if not found:
                if not config_prop.required or config_prop.default is not None:
                    self._set_instance_prop(attr_name, config_prop, config_prop.default)
                else:
                    raise ValueError('Missing required ConfigProperty {}'.format(attr_name))
1197409
def read_config(io = nil)
      unless io
        root_path = ::Middleman::Application.root
        config_file_path = File.join(root_path, ".s3_sync")

        # skip if config file does not exist
        return unless File.exists?(config_file_path)

        io = File.open(config_file_path, "r")
      end

      config = (YAML.load(io) || {}).symbolize_keys

      config.each do |key, value|
        options[key.to_sym] = value
      end
    end
312320
def from_config(cls, config):
        """"""
        auth_key = None
        password_file = config["authentication.passwordFile"]
        if password_file is not None:
            try:
                auth_key = open(config["authentication.passwordFile"]).read()
                auth_key = re.sub(r"\s", "", auth_key)
            except IOError:
                LOG.error("Could not load password file!")
                sys.exit(1)
        password = config["authentication.password"]
        if password is not None:
            auth_key = password
        connector = Connector(
            mongo_address=config["mainAddress"],
            doc_managers=config["docManagers"],
            oplog_checkpoint=os.path.abspath(config["oplogFile"]),
            collection_dump=config["onlyDump"] or not config["noDump"],
            only_dump=config["onlyDump"],
            batch_size=config["batchSize"],
            continue_on_error=config["continueOnError"],
            auth_username=config["authentication.adminUsername"],
            auth_key=auth_key,
            fields=config["fields"],
            exclude_fields=config["exclude_fields"],
            ns_set=config["namespaces.include"],
            ex_ns_set=config["namespaces.exclude"],
            dest_mapping=config["namespaces.mapping"],
            namespace_options=config["namespaces.namespace_options"],
            gridfs_set=config["namespaces.gridfs"],
            ssl_certfile=config["ssl.sslCertfile"],
            ssl_keyfile=config["ssl.sslKeyfile"],
            ssl_ca_certs=config["ssl.sslCACerts"],
            ssl_cert_reqs=config["ssl.sslCertificatePolicy"],
            tz_aware=config["timezoneAware"],
        )
        return connector
561897
@Override
    protected synchronized void loadConfiguration() throws IOException {
        final ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
        final TypeReference<HashMap<String, String>> typeRef = new TypeReference<HashMap<String, String>>() {};
        namespaces = mapper.readValue(new File(configPath), typeRef);
    }
298444
public function init()
    {
        $kubernetesClient = $this->controller->getKubernetesClient();
        $storeNamespace = $this->namespace;
        $storeName = $this->name;

        // check for ConfigMap existence
        $response = $kubernetesClient->request("/api/v1/namespaces/${storeNamespace}/configmaps/${storeName}");
        if ($response['status'] == 'Failure') {
            // create ConfigMap
            $data = [
                'kind' => 'ConfigMap',
                'metadata' => [
                    'name' => $storeName,
                ],
                'data' => null,
            ];

            // check for success
            $response = $kubernetesClient->request("/api/v1/namespaces/${storeNamespace}/configmaps", 'POST', [], $data);
            if ($response['status'] == 'Failure') {
                $this->log($response['message']);
                return;
            }
        }

        // load initial data
        if (!empty($response['data'])) {
            array_walk($response['data'], function (&$item, $key) {
                $item = json_decode($item, true);
            });
        }
        $this->data = $response['data'];

        // create watch
        $params = [
            'resourceVersion' => $response['metadata']['resourceVersion'],
        ];
        $watch = $kubernetesClient->createWatch("/api/v1/watch/namespaces/${storeNamespace}/configmaps/${storeName}", $params, $this->getConfigMapWatchCallback());
        $this->addWatch($watch);

        $this->initialized = true;
        $this->controller->log('store successfully initialized');
    }
228613
def load(config_file):
    
    with open(config_file, "r") as f:

        def env_get():
            return dict(os.environ)
        tmpl = Template(f.read())
        return Config(yaml.load(tmpl.render(**env_get())))
223362
def read_kioslaverc (kde_config_dir):
    """"""
    data = {}
    filename = os.path.join(kde_config_dir, "kioslaverc")
    with open(filename) as fd:
        # First read all lines into dictionary since they can occur
        # in any order.
        for line in  fd:
            line = line.rstrip()
            if line.startswith('['):
                in_proxy_settings = line.startswith("[Proxy Settings]")
            elif in_proxy_settings:
                if '=' not in line:
                    continue
                key, value = line.split('=', 1)
                key = key.strip()
                value = value.strip()
                if not key:
                    continue
                # trim optional localization
                key = loc_ro.sub("", key).strip()
                if not key:
                    continue
                add_kde_setting(key, value, data)
    resolve_kde_settings(data)
    return data
617359
def _load_config():
    """"""
    fname = _get_config_fname()
    if fname is None or not op.isfile(fname):
        return dict()
    with open(fname, 'r') as fid:
        config = json.load(fid)
    return config
985000
protected function loadConfig()
    {
        $this->container['app']->getConfig()->load($this->getConfigFiles());

        $this->dispatchEvent(KernelEvents::CONFIG_LOADED, new KernelEvent($this->container));
    }
150077
def load(self):
        """"""

        # Config files prior to 0.2.4 dor not have config version keys
        old_config = not self.cfg_file.Exists("config_version")

        # Reset data
        self.data.__dict__.update(self.defaults.__dict__)

        for key in self.defaults.__dict__:
            if self.cfg_file.Exists(key):
                setattr(self.data, key, self.cfg_file.Read(key))

        # Reset keys that should be reset on version upgrades
        if old_config or self.version != self.data.config_version:
            for key in self.reset_on_version_change:
                setattr(self.data, key, getattr(DefaultConfig(), key))
            self.data.config_version = self.version

        # Delete gpg_key_uid and insert fingerprint key

        if hasattr(self.data, "gpg_key_uid"):
            oldkey = "gpg_key_uid"
            delattr(self.data, oldkey)
            newkey = "gpg_key_fingerprint"
            setattr(self.data, newkey, getattr(DefaultConfig(), newkey))