From 0c78c2ed61c84ff967c2e6894f5dcff0987c2dec Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Mon, 28 Nov 2011 14:38:34 +0000 Subject: [PATCH] Remove extra_context support in Flags This doesn't seem to be used at all any more. Change-Id: I3a4a1eb271f547ad1723676dc47f1d8c8bad88ea --- nova/flags.py | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/nova/flags.py b/nova/flags.py index e0f1ceded03b..dc4e648f0008 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -68,10 +68,9 @@ class FlagValues(object): a = self._error_msg[self._error_msg.rindex(": --") + 2:] return filter(lambda i: i == a or i.startswith(a + "="), args)[0] - def __init__(self, extra_context=None): + def __init__(self): self._parser = optparse.OptionParser() self._parser.disable_interspersed_args() - self._extra_context = extra_context self._multistring_defaults = {} self.Reset() @@ -138,8 +137,7 @@ class FlagValues(object): val = getattr(self._values, name) if type(val) is str: tmpl = string.Template(val) - context = [self, self._extra_context] - return tmpl.substitute(StrWrapper(context)) + return tmpl.substitute(vars(self._values)) return val def get(self, name, default): @@ -220,24 +218,6 @@ class FlagValues(object): FLAGS = FlagValues() -class StrWrapper(object): - """Wrapper around FlagValues objects. - - Wraps FlagValues objects for string.Template so that we're - sure to return strings. - - """ - def __init__(self, context_objs): - self.context_objs = context_objs - - def __getitem__(self, name): - for context in self.context_objs: - val = getattr(context, name, False) - if val: - return str(val) - raise KeyError(name) - - def DEFINE_string(name, default, help, flag_values=FLAGS): flag_values.define_string(name, default, help)