From 30b238ef6db7c5b5b6d80c1e51aa2600e896abe2 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 28 Jun 2021 23:27:16 -0400 Subject: SBoTools: add sbomaint (maintainer search) --- SBoTools/plugin.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'SBoTools') diff --git a/SBoTools/plugin.py b/SBoTools/plugin.py index 47fc28b..7ffd824 100644 --- a/SBoTools/plugin.py +++ b/SBoTools/plugin.py @@ -220,4 +220,47 @@ class SBoTools(callbacks.Plugin): sboinfo = thread(wrap(sboinfo, ['somethingWithoutSpaces'])) + def sbomaint(self, irc, msg, args, terms): + """ + + Show list of SBo builds whose maintainers match the search term. + """ + + term = str.join(' ', terms) + like = '%' + term + '%' + + maxdeps = self.getMaxDeps(msg) + + db = self.InitDB(); + cursor = db.cursor() + cursor.execute("select c.name, b.name, m.name, e.addr from categories c, builds b, maintainers m, emails e where c.id=b.category and b.maintainer=m.id and b.email=e.id and (m.name like ? or e.addr like ?) order by m.name, e.addr, b.id", (like, like,)) + result = cursor.fetchall() + + if(len(result) == 0): + irc.reply("No matching maintainer names or email addresses") + return + + lines = [] + + toomany = (len(result) > maxdeps) + if(toomany): + lines.append(str(len(result)) + " results, showing " + str(maxdeps) + ".") + del result[maxdeps:] + + oldnamemail = "" + for (cat, build, maint, email) in result: + namemail = maint + " <" + email + ">" + if(namemail != oldnamemail): + if(oldnamemail != ""): + lines.append("|") + lines.append(namemail + ":") + oldnamemail = namemail + lines.append(ircutils.bold(cat + "/" + build)) + if(toomany): + lines.append("...") + + irc.replies(lines, joiner=" ") + + sbomaint = thread(wrap(sbomaint, [many('somethingWithoutSpaces')])) + Class = SBoTools -- cgit v1.2.3