From 7457452a88b63505e3c90bbf218be7140713ffb5 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Fri, 10 Aug 2012 11:18:23 +0100 Subject: Sync with latest version of openstack.common.cfg Changes since last sync: - Modifies _is_opt_registered fcn to check for duplicate opts - allow empty config values Change-Id: I5150404a0ff97f37d1d1f1b778736fa385d33860 --- nova/openstack/common/cfg.py | 5 ++++- nova/openstack/common/iniparser.py | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'nova/openstack') diff --git a/nova/openstack/common/cfg.py b/nova/openstack/common/cfg.py index 64411180f..c0b0161ff 100644 --- a/nova/openstack/common/cfg.py +++ b/nova/openstack/common/cfg.py @@ -464,7 +464,7 @@ def _is_opt_registered(opts, opt): :raises: DuplicateOptError if a naming conflict is detected """ if opt.dest in opts: - if opts[opt.dest]['opt'] is not opt: + if opts[opt.dest]['opt'] != opt: raise DuplicateOptError(opt.name) return True else: @@ -527,6 +527,9 @@ class Opt(object): else: self.deprecated_name = None + def __ne__(self, another): + return vars(self) != vars(another) + def _get_from_config_parser(self, cparser, section): """Retrieves the option value from a MultiConfigParser object. diff --git a/nova/openstack/common/iniparser.py b/nova/openstack/common/iniparser.py index e91eea538..241284449 100644 --- a/nova/openstack/common/iniparser.py +++ b/nova/openstack/common/iniparser.py @@ -53,7 +53,8 @@ class BaseParser(object): key, value = line[:colon], line[colon + 1:] value = value.strip() - if value[0] == value[-1] and value[0] == "\"" or value[0] == "'": + if ((value and value[0] == value[-1]) and + (value[0] == "\"" or value[0] == "'")): value = value[1:-1] return key.strip(), [value] -- cgit