summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Hellmann <doug.hellmann@gmail.com>2013-07-24 03:54:56 -0700
committerDoug Hellmann <doug.hellmann@gmail.com>2013-07-24 03:54:56 -0700
commit8b5f9a794dc2012b32dc10382798c783023f1f01 (patch)
tree3a186e9ef830971264594c87fd146a46e35b8b23
parent3c08b794b211ebc018089a74d8af7b9b5489cbb5 (diff)
parent3fdc256143d03d2c5b95aab673028b893abeb508 (diff)
downloadcliff-8b5f9a794dc2012b32dc10382798c783023f1f01.tar.gz
Merge pull request #37 from dtroyer/make-columns
Add make_columns() to show.ShowOne
-rw-r--r--cliff/show.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/cliff/show.py b/cliff/show.py
index 39e94b1..855b2d2 100644
--- a/cliff/show.py
+++ b/cliff/show.py
@@ -44,3 +44,12 @@ class ShowOne(DisplayCommandBase):
self.app.stdout,
parsed_args)
return 0
+
+ def dict2columns(self, data):
+ """Implement the common task of converting a dict-based object
+ to the two-column output that ShowOne expects.
+ """
+ if not data:
+ return ({}, {})
+ else:
+ return zip(*sorted(data.items()))