diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-05-14 15:20:45 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-05-14 15:20:45 +0000 |
| commit | 13d2821bb7cdfeae07774026456f7daa7d8026bc (patch) | |
| tree | a787f77ec4d9c4d5b04bff214e3d1c2b877d746f /openstack | |
| parent | 2e1371a13205cd494dc4b9ade79ae20b607256b1 (diff) | |
| parent | 05bc19d4e96052463062b6b8ca83852b4b169d48 (diff) | |
| download | oslo-13d2821bb7cdfeae07774026456f7daa7d8026bc.tar.gz oslo-13d2821bb7cdfeae07774026456f7daa7d8026bc.tar.xz oslo-13d2821bb7cdfeae07774026456f7daa7d8026bc.zip | |
Merge "cfg: make reset() clear defaults and overrides"
Diffstat (limited to 'openstack')
| -rw-r--r-- | openstack/common/cfg.py | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/openstack/common/cfg.py b/openstack/common/cfg.py index 31d727b..c50aa6a 100644 --- a/openstack/common/cfg.py +++ b/openstack/common/cfg.py @@ -940,7 +940,7 @@ class ConfigOpts(collections.Mapping): :raises: SystemExit, ConfigFilesNotFoundError, ConfigFileParseError, RequiredOptError """ - self.reset() + self.clear() self._args = args @@ -987,11 +987,16 @@ class ConfigOpts(collections.Mapping): """Return the number of options and option groups.""" return len(self._opts) + len(self._groups) - @__clear_cache def reset(self): - """Reset the state of the object to before it was called.""" + """Clear the object state and unset overrides and defaults.""" + self._unset_defaults_and_overrides() + self.clear() + + @__clear_cache + def clear(self): + """Clear the state of the object to before it was called.""" self._args = None - self._cli_values = None + self._cli_values = {} self._cparser = None @__clear_cache @@ -1098,6 +1103,17 @@ class ConfigOpts(collections.Mapping): opt_info = self._get_opt_info(name, group) opt_info['default'] = default + def _unset_defaults_and_overrides(self): + """Unset any default or override on all options.""" + def unset(opts): + for info in opts.values(): + info['default'] = None + info['override'] = None + + unset(self._opts) + for group in self._groups.values(): + unset(group._opts) + def disable_interspersed_args(self): """Set parsing to stop on the first non-option. |
