diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-12-08 00:41:01 +0100 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-12-08 03:28:52 +0100 |
| commit | 7b4f72fa7a19b7c38312a6f6fd553ca45f04e9a6 (patch) | |
| tree | 55204b085afcb0316249eda97fee345694719b2e /menuconfig.py | |
| parent | 166be7d7684b4bd309661603a35710e0ed752680 (diff) | |
Make {load,write}_config(filename=None) implement the standard behavior
Make the previously obligatory 'filename' argument to load_config() and
write_config() default to None, and have that implement the behavior
you'd usually want: read/write either KCONFIG_CONFIG or ".config" if
unset, and read the 'option defconfig_list' configuration file if
KCONFIG_CONFIG/".config" doesn't exist.
For load_config(), filename=None also allows the configuration file to
be missing without raising an error. load_config() returns True if a
local configuration file was loaded, which is useful to check in the
menuconfig (if no local configuration file exists, we always want to
prompt for saving the configuration when exiting).
Also add a 'verbose' argument (default True) to load_config() and
read_config() that makes them print which files were read/written in
filename=None mode.
Also generalize olddefconfig.py and oldconfig.py to not require there to
already be a local configuration file. This was a bit silly for
olddefconfig.py in particular.
Remove the examples/defconfig.py script. It's a duplicate of
olddefconfig.py.
Diffstat (limited to 'menuconfig.py')
| -rwxr-xr-x | menuconfig.py | 35 |
1 files changed, 8 insertions, 27 deletions
diff --git a/menuconfig.py b/menuconfig.py index 6c1d1ce..eebe3a0 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -608,39 +608,20 @@ def menuconfig(kconf): Kconfig instance to be configured """ global _kconf - global _config_filename global _show_all global _conf_changed _kconf = kconf - _config_filename = standard_config_filename() - - if os.path.exists(_config_filename): - _conf_changed = False - print("Using existing configuration '{}' as base" - .format(_config_filename)) - _kconf.load_config(_config_filename) - - else: - # Always prompt for save if the .config doesn't exist - _conf_changed = True - - if kconf.defconfig_filename is not None: - print("Using default configuration found in '{}' as base" - .format(kconf.defconfig_filename)) - _kconf.load_config(kconf.defconfig_filename) - - else: - print("Using default symbol values as base") - + # Always prompt for save if the configuration file doesn't exist + _conf_changed = not kconf.load_config() # Any visible items in the top menu? _show_all = False - if not _shown_nodes(_kconf.top_node): + if not _shown_nodes(kconf.top_node): # Nothing visible. Start in show-all mode and try again. _show_all = True - if not _shown_nodes(_kconf.top_node): + if not _shown_nodes(kconf.top_node): # Give up. The implementation relies on always having a selected # node. print("Empty configuration -- nothing to configure.\n" @@ -649,7 +630,7 @@ def menuconfig(kconf): # Disable warnings. They get mangled in curses mode, and we deal with # errors ourselves. - _kconf.disable_warnings() + kconf.disable_warnings() # Make curses use the locale settings specified in the environment locale.setlocale(locale.LC_ALL, "") @@ -821,7 +802,7 @@ def _menuconfig(stdscr): _conf_changed = False elif c in ("s", "S"): - if _save_dialog(_kconf.write_config, _config_filename, + if _save_dialog(_kconf.write_config, standard_config_filename(), "configuration"): _conf_changed = False @@ -869,11 +850,11 @@ def _quit_dialog(): return None if c == "y": - if _try_save(_kconf.write_config, _config_filename, + if _try_save(_kconf.write_config, standard_config_filename(), "configuration"): return "Configuration saved to '{}'" \ - .format(_config_filename) + .format(standard_config_filename()) elif c == "n": return "Configuration was not saved" |
