Remove printt
Remove unused common.utils functions prettyprint 0.6 removed printt at the last minute, our references to it turned out to be in unused code; remove it. Change-Id: I38a4d9a169beaecfd53eafc5b10f06201bac0c31
This commit is contained in:
parent
70b3246a19
commit
a7da2b8008
@ -27,45 +27,6 @@ import prettytable
|
|||||||
from openstackclient.common import exceptions
|
from openstackclient.common import exceptions
|
||||||
|
|
||||||
|
|
||||||
# Decorator for cli-args
|
|
||||||
def arg(*args, **kwargs):
|
|
||||||
def _decorator(func):
|
|
||||||
# Because of the sematics of decorator composition if we just append
|
|
||||||
# to the options list positional options will appear to be backwards.
|
|
||||||
func.__dict__.setdefault('arguments', []).insert(0, (args, kwargs))
|
|
||||||
return func
|
|
||||||
return _decorator
|
|
||||||
|
|
||||||
|
|
||||||
def pretty_choice_list(l):
|
|
||||||
return ', '.join("'%s'" % i for i in l)
|
|
||||||
|
|
||||||
|
|
||||||
def print_list(objs, fields, formatters={}):
|
|
||||||
pt = prettytable.PrettyTable([f for f in fields], caching=False)
|
|
||||||
pt.aligns = ['l' for f in fields]
|
|
||||||
|
|
||||||
for o in objs:
|
|
||||||
row = []
|
|
||||||
for field in fields:
|
|
||||||
if field in formatters:
|
|
||||||
row.append(formatters[field](o))
|
|
||||||
else:
|
|
||||||
field_name = field.lower().replace(' ', '_')
|
|
||||||
data = getattr(o, field_name, '')
|
|
||||||
row.append(data)
|
|
||||||
pt.add_row(row)
|
|
||||||
|
|
||||||
pt.printt(sortby=fields[0])
|
|
||||||
|
|
||||||
|
|
||||||
def print_dict(d):
|
|
||||||
pt = prettytable.PrettyTable(['Property', 'Value'], caching=False)
|
|
||||||
pt.aligns = ['l', 'l']
|
|
||||||
[pt.add_row(list(r)) for r in d.iteritems()]
|
|
||||||
pt.printt(sortby='Property')
|
|
||||||
|
|
||||||
|
|
||||||
def find_resource(manager, name_or_id):
|
def find_resource(manager, name_or_id):
|
||||||
"""Helper for the _find_* methods."""
|
"""Helper for the _find_* methods."""
|
||||||
# first try to get entity as integer id
|
# first try to get entity as integer id
|
||||||
@ -91,21 +52,6 @@ def find_resource(manager, name_or_id):
|
|||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
|
|
||||||
|
|
||||||
def skip_authentication(f):
|
|
||||||
"""Function decorator used to indicate a caller may be unauthenticated."""
|
|
||||||
f.require_authentication = False
|
|
||||||
return f
|
|
||||||
|
|
||||||
|
|
||||||
def is_authentication_required(f):
|
|
||||||
"""Checks to see if the function requires authentication.
|
|
||||||
|
|
||||||
Use the skip_authentication decorator to indicate a caller may
|
|
||||||
skip the authentication step.
|
|
||||||
"""
|
|
||||||
return getattr(f, 'require_authentication', True)
|
|
||||||
|
|
||||||
|
|
||||||
def string_to_bool(arg):
|
def string_to_bool(arg):
|
||||||
return arg.strip().lower() in ('t', 'true', 'yes', '1')
|
return arg.strip().lower() in ('t', 'true', 'yes', '1')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user