From 080dbc0e79c7a27903d449cd8f1e2309cda9a27b Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 13 Oct 2014 18:24:39 -0700 Subject: [PATCH] Add mintpkg command for parsing Linux Mint's repositories (still needs testing) --- PkgInfo/plugin.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/PkgInfo/plugin.py b/PkgInfo/plugin.py index 6e5ba3b..1116d1c 100644 --- a/PkgInfo/plugin.py +++ b/PkgInfo/plugin.py @@ -209,6 +209,39 @@ class PkgInfo(callbacks.Plugin): irc.reply(s) pkgsearch = wrap(pkgsearch, ['somethingWithoutSpaces', 'somethingWithoutSpaces']) + def mintpkg(self, irc, msg, args, release, query): + """ + + Looks up in Linux Mint's repositories.""" + if not bs4Present: + irc.error("This command requires the Beautiful Soup 4 library. See" + " https://github.com/GLolol/SupyPlugins/blob/master/README.md" + "#pkginfo for instructions on how to install it.", Raise=True) + addr = 'http://packages.linuxmint.com/list.php?release=' + quote(release) + try: + fd = utils.web.getUrl(addr).decode("utf-8") + except Exception as e: + irc.error(str(e), Raise=True) + soup = BeautifulSoup(fd) + results = soup.find_all("td") + found = {} + for result in results: + name = result.contents[0].string + if query == name: + self.log.info(str(result.contents)) + version, pkg = result.next_sibling.next_sibling.string, name + found[pkg] = version + self.log.info(str(found)) + if found: + s = 'Found %s results: ' % len(found) + for x in found: + s += '%s \x02(%s)\x02, ' % (x, found[x]) + s += 'View more at: %s' % addr + irc.reply(s) + else: + irc.error('No results found.') + mintpkg = wrap(mintpkg, ['somethingWithoutSpaces', 'somethingWithoutSpaces']) + Class = PkgInfo