Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : search
---------------------------------------------------------------
commit ae10dd4add58065e2af8a876940b28f66af7c769
Author: Igor Gnatenko <i.gnatenko.brain(a)gmail.com>
Date: Sat Mar 1 14:54:51 2014 +0400
dnf-plugin: search for fulltext
Signed-off-by: Igor Gnatenko <i.gnatenko.brain(a)gmail.com>
---------------------------------------------------------------
dnf-plugin/copr_hook.py | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/dnf-plugin/copr_hook.py b/dnf-plugin/copr_hook.py
index cc546c8..c18e550 100644
--- a/dnf-plugin/copr_hook.py
+++ b/dnf-plugin/copr_hook.py
@@ -121,7 +121,7 @@ search project""")
print "{}".format(desc)
i += 1
elif subcommand == "search":
- #http://copr.fedoraproject.org/api/coprs/search/ocltoys/
+ #http://copr.fedoraproject.org/api/coprs/search/tests/
api_path = "/api/coprs/search/{}/".format(project_name)
opener = urllib.FanceURLopener({})
@@ -131,8 +131,23 @@ search project""")
except ValueError:
raise dnf.Exceptions.Error(_("Can't parse search for
'{}'.").format(project_name)), None, sys.exc_info()[2]
i = 0
+ lmax = 0
while i < len(json_parse["repos"]):
- print
"{0}/{1}".format(json_parse["users"][i]["name"],
project_name)
+ lnow = len("{0}/{1}:
".format(json_parse["repos"][i]["username"],
json_parse["repos"][i]["coprname"]))
+ if lnow > lmax:
+ lmax = lnow
+ i += 1
+ i = 0
+ while i < len(json_parse["repos"]):
+ repo = "{0}/{1}:
".format(json_parse["repos"][i]["username"],
json_parse["repos"][i]["coprname"])
+ 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
else:
raise dnf.exceptions.Error(_('Unknown subcommand
{}.').format(subcommand))