summaryrefslogtreecommitdiffstats
path: root/ipalib/cli.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-11-17 15:27:08 -0700
committerJason Gerard DeRose <jderose@redhat.com>2008-11-17 15:27:08 -0700
commit42bf555a3ad1f1777b26a4092b49512b9360c882 (patch)
tree82ec2c847b81f44a9e060957a505e05c6f70a273 /ipalib/cli.py
parente7ec4131589d5d387c4257bca76e91a17ad7e1a3 (diff)
downloadfreeipa-42bf555a3ad1f1777b26a4092b49512b9360c882.tar.gz
freeipa-42bf555a3ad1f1777b26a4092b49512b9360c882.tar.xz
freeipa-42bf555a3ad1f1777b26a4092b49512b9360c882.zip
Started updated user_* commands to use textui
Diffstat (limited to 'ipalib/cli.py')
-rw-r--r--ipalib/cli.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py
index fc58f2e95..1c7256a2a 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.