[kupfer] plugins: Adjust --list-plugins format
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] plugins: Adjust --list-plugins format
- Date: Fri, 11 Dec 2009 16:22:21 +0000 (UTC)
commit cd099c43c126d2c971144ee1e43041b4d87d11bd
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Mon Nov 30 23:17:38 2009 +0100
plugins: Adjust --list-plugins format
Fix justification and alignment so that plugin id, version and
description columns are aligned better.
kupfer/plugins.py | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/kupfer/plugins.py b/kupfer/plugins.py
index 51e3a95..387891b 100644
--- a/kupfer/plugins.py
+++ b/kupfer/plugins.py
@@ -86,15 +86,24 @@ def get_plugin_info():
}
def get_plugin_desc():
+ """Return a formatted list of plugins suitable for printing to terminal"""
import textwrap
+ infos = list(get_plugin_info())
+ verlen = max(len(r["version"]) for r in infos)
+ idlen = max(len(r["name"]) for r in infos)
+ maxlen = 78
+ left_margin = 2 + idlen + 1 + verlen + 1
desc = []
for rec in get_plugin_info():
# Wrap the description and align continued lines
- maxlen = 80
- left_margin = 2 + 20 + 6
wrapped = textwrap.wrap(rec["description"], maxlen - left_margin)
- rec["description"] = (u"\n" + u" "*left_margin).join(wrapped)
- desc.append(_(""" %(name)-20s %(version)-4s %(description)s""") % rec)
+ description = (u"\n" + u" "*left_margin).join(wrapped)
+ desc.append(" %s %s %s" %
+ (
+ rec["name"].ljust(idlen),
+ rec["version"].ljust(verlen),
+ description,
+ ))
return "\n".join(desc)
imported_plugins = {}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]