From 42bf555a3ad1f1777b26a4092b49512b9360c882 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Mon, 17 Nov 2008 15:27:08 -0700 Subject: Started updated user_* commands to use textui --- ipalib/cli.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'ipalib/cli.py') diff --git a/ipalib/cli.py b/ipalib/cli.py index fc58f2e9..1c7256a2 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -198,6 +198,28 @@ class textui(backend.Backend): for (key, value) in rows: self.print_indented('%s = %r' % (key, value), indent) + def print_entry(self, entry, indent=1): + """ + Print an ldap entry dict. + + For example: + + >>> entry = dict(sn='Last', givenname='First', uid='flast') + >>> ui = textui() + >>> ui.print_entry(entry) + givenname: 'First' + sn: 'Last' + uid: 'flast' + """ + assert type(entry) is dict + for key in sorted(entry): + value = entry[key] + if type(value) in (list, tuple): + value = ', '.join(repr(v) for v in value) + else: + value = repr(value) + self.print_indented('%s: %s' % (key, value), indent) + def print_dashed(self, string, above=True, below=True): """ Print a string with a dashed line above and/or below. -- cgit