Remove extra_context support in Flags
This doesn't seem to be used at all any more. Change-Id: I3a4a1eb271f547ad1723676dc47f1d8c8bad88ea
This commit is contained in:
parent
45e31ab90d
commit
0c78c2ed61
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user