diff --git a/openstackclient/common/utils.py b/openstackclient/common/utils.py index 9e704c9792..fe0e5bcbd8 100644 --- a/openstackclient/common/utils.py +++ b/openstackclient/common/utils.py @@ -27,45 +27,6 @@ import prettytable 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): """Helper for the _find_* methods.""" # first try to get entity as integer id @@ -91,21 +52,6 @@ def find_resource(manager, name_or_id): 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): return arg.strip().lower() in ('t', 'true', 'yes', '1')