Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : search
---------------------------------------------------------------
commit 18afdcd8d123173a6e42f1e8fb9dfb364e54d7fe
Author: Igor Gnatenko <i.gnatenko.brain(a)gmail.com>
Date: Sun Feb 16 17:39:22 2014 +0400
dnf-plugin: implement search
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 eeddc8c..338d879 100644
--- a/dnf-plugin/copr_hook.py
+++ b/dnf-plugin/copr_hook.py
@@ -36,6 +36,7 @@ class CoprCommand(dnf.cli.Command):
copr enable ignatenkobrain/ocltoys
copr disable rhscl/perl516
copr list ignatenkobrain
+ copr search ocltoys
""")
@staticmethod
@@ -44,7 +45,8 @@ class CoprCommand(dnf.cli.Command):
return _("""
enable name/project [chroot]
disable name/project
-list name""")
+list name
+search project""")
def run(self, extcmds):
# FIXME this should do dnf itself (BZ#1062889)
@@ -102,6 +104,20 @@ list name""")
while i < len(json_parse["repos"]):
print "{0}/{1}".format(project_name,
json_parse["repos"][i]["name"])
i += 1
+ elif subcommand == "search":
+ #http://copr.fedoraproject.org/api/coprs/search/ocltoys/
+ api_path = "/api/coprs/search/{}/".format(project_name)
+
+ opener = urllib.FanceURLopener({})
+ res = opener.open(base_url+api_path)
+ try:
+ json_parse = json.loads(res.read())
+ except ValueError:
+ raise dnf.Exceptions.Error(_("Can't parse search for
'{}'.").format(project_name)), None, sys.exc_info()[2]
+ i = 0
+ while i < len(json_parse["repos"]):
+ print
"{0}/{1}".format(json_parse["users"][i]["name"],
project_name)
+ i += 1
else:
raise dnf.exceptions.Error(_('Unknown subcommand
{}.').format(subcommand))