[copr] search: dnf-plugin: print discription (5ebac89)
by Igor Gnatenko
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : search
>---------------------------------------------------------------
commit 5ebac892c11e755811768bc9c6979b1839c87003
Author: Igor Gnatenko <i.gnatenko.brain(a)gmail.com>
Date: Sat Mar 1 14:32:13 2014 +0400
dnf-plugin: print discription
Signed-off-by: Igor Gnatenko <i.gnatenko.brain(a)gmail.com>
>---------------------------------------------------------------
dnf-plugin/copr_hook.py | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/dnf-plugin/copr_hook.py b/dnf-plugin/copr_hook.py
index 338d879..cc546c8 100644
--- a/dnf-plugin/copr_hook.py
+++ b/dnf-plugin/copr_hook.py
@@ -7,6 +7,7 @@ from dnf.yum.i18n import _
from urlgrabber import grabber
import urllib
import json
+import re
yes = set([_('yes'), _('y')])
no = set([_('no'), _('n'), ''])
@@ -101,8 +102,23 @@ search project""")
except ValueError:
raise dnf.exceptions.Error(_("Can't parse repositories for username '{}'.").format(project_name)), None, sys.exc_info()[2]
i = 0
+ lmax = 0
while i < len(json_parse["repos"]):
- print "{0}/{1}".format(project_name, json_parse["repos"][i]["name"])
+ lnow = len("{0}/{1}: ".format(project_name, json_parse["repos"][i]["name"]))
+ if lnow > lmax:
+ lmax = lnow
+ i += 1
+ i = 0
+ while i < len(json_parse["repos"]):
+ repo = "{0}/{1}: ".format(project_name, json_parse["repos"][i]["name"])
+ tmp_str = json_parse["repos"][i]["description"]
+ tmp_list = [y for y in (x.strip() for x in tmp_str.splitlines()) if y]
+ if tmp_list == []:
+ tmp_list = [_("No description given")]
+ tmp_list = [re.sub(r"^", " " * lmax, w) for w in tmp_list if w]
+ print "{}".format(repo)
+ for desc in tmp_list:
+ print "{}".format(desc)
i += 1
elif subcommand == "search":
#http://copr.fedoraproject.org/api/coprs/search/ocltoys/
10 years, 2 months