From 6f58f38748085e6a104de6f9e992469d3b685d5a Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Fri, 7 Jan 2011 11:17:55 -0500 Subject: Display the entries that failed when deleting with --continue. We collected the failures but didn't report it back. This changes the API of most delete commands so rather than returning a boolean it returns a dict with the only current key as failed. This also adds a new parameter flag, suppress_empty. This will try to not print values that are empty if included. This makes the output of the delete commands a bit prettier. ticket 687 --- ipalib/cli.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'ipalib/cli.py') diff --git a/ipalib/cli.py b/ipalib/cli.py index 436607f2..892db808 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -326,16 +326,16 @@ class textui(backend.Backend): for attr in sorted(entry): print_attr(attr) - def print_entries(self, entries, order=None, labels=None, print_all=True, format='%s: %s', indent=1): + def print_entries(self, entries, order=None, labels=None, flags=None, print_all=True, format='%s: %s', indent=1): assert isinstance(entries, (list, tuple)) first = True for entry in entries: if not first: print '' first = False - self.print_entry(entry, order, labels, print_all, format, indent) + self.print_entry(entry, order, labels, flags, print_all, format, indent) - def print_entry(self, entry, order=None, labels=None, print_all=True, format='%s: %s', indent=1): + def print_entry(self, entry, order=None, labels=None, flags=None, print_all=True, format='%s: %s', indent=1): """ """ if isinstance(entry, (list, tuple)): @@ -351,7 +351,10 @@ class textui(backend.Backend): if key not in entry: continue label = labels.get(key, key) + flag = flags.get(key, []) value = entry[key] + if 'suppress_empty' in flag and value in [u'', '', [], None]: + continue if isinstance(value, dict): if frontend.entry_count(value) == 0: continue -- cgit