Get all available subscriptions for details command
Add a new method get_object_list to ReplApplication Should close #846.
This commit is contained in:
parent
c9616639af
commit
92d5e9ea0f
2 changed files with 43 additions and 23 deletions
|
|
@ -45,6 +45,7 @@ __all__ = ['NotEnoughArguments', 'ReplApplication']
|
|||
class NotEnoughArguments(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class ReplOptionParser(OptionParser):
|
||||
def format_option_help(self, formatter=None):
|
||||
if not formatter:
|
||||
|
|
@ -53,6 +54,7 @@ class ReplOptionParser(OptionParser):
|
|||
return '%s\n%s' % (formatter.format_commands(self.commands),
|
||||
OptionParser.format_option_help(self, formatter))
|
||||
|
||||
|
||||
class ReplOptionFormatter(IndentedHelpFormatter):
|
||||
def format_commands(self, commands):
|
||||
s = u''
|
||||
|
|
@ -67,6 +69,7 @@ class ReplOptionFormatter(IndentedHelpFormatter):
|
|||
s += ' %s\n' % c
|
||||
return s
|
||||
|
||||
|
||||
class ReplApplication(Cmd, ConsoleApplication):
|
||||
"""
|
||||
Base application class for Repl applications.
|
||||
|
|
@ -211,6 +214,18 @@ class ReplApplication(Cmd, ConsoleApplication):
|
|||
backend.fillobj(obj, fields)
|
||||
return obj
|
||||
|
||||
def get_object_list(self, method=None):
|
||||
# return cache if not empty
|
||||
if len(self.objects) > 0:
|
||||
return self.objects
|
||||
elif method is not None:
|
||||
for backend, object in self.do(method):
|
||||
self.add_object(object)
|
||||
return self.objects
|
||||
# XXX: what can we do without method?
|
||||
else:
|
||||
return tuple()
|
||||
|
||||
def unload_backends(self, *args, **kwargs):
|
||||
self.objects = []
|
||||
self.collections = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue