Skip to content

Commit 23f422a

Browse files
jroheldmach
authored andcommitted
Setup configuration values using C++ bindings
Using _get_option() is still required. It is used as a fallback for options that are present only in Python.
1 parent a9bc7fd commit 23f422a

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

dnf/conf/config.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -277,22 +277,25 @@ def _populate(self, parser, section, filename, priority=PRIO_DEFAULT):
277277
if not value or value == 'None':
278278
value = None
279279

280-
opt = self._get_option(name)
281-
if opt: # and not opt._is_runtimeonly():
282-
try:
283-
if value is not None:
284-
opt._set(value, priority)
285-
except dnf.exceptions.ConfigError as e:
286-
logger.debug(_('Unknown configuration value: '
287-
'%s=%s in %s; %s'), ucd(name),
288-
ucd(value), ucd(filename), e.raw_error)
289-
else:
290-
if name == 'arch' and hasattr(self, name):
291-
setattr(self, name, value)
280+
try:
281+
self._config.optBinds().at(name).newString(priority, value)
282+
except RuntimeError:
283+
opt = self._get_option(name)
284+
if opt: # and not opt._is_runtimeonly():
285+
try:
286+
if value is not None:
287+
opt._set(value, priority)
288+
except dnf.exceptions.ConfigError as e:
289+
logger.debug(_('Unknown configuration value: '
290+
'%s=%s in %s; %s'), ucd(name),
291+
ucd(value), ucd(filename), e.raw_error)
292292
else:
293-
logger.debug(
294-
_('Unknown configuration option: %s = %s in %s'),
295-
ucd(name), ucd(value), ucd(filename))
293+
if name == 'arch' and hasattr(self, name):
294+
setattr(self, name, value)
295+
else:
296+
logger.debug(
297+
_('Unknown configuration option: %s = %s in %s'),
298+
ucd(name), ucd(value), ucd(filename))
296299

297300
# def _config_items(self):
298301
"""Yield (name, value) pairs for every option in the instance."""

0 commit comments

Comments
 (0)