diff --git a/PkgInfo/README.md b/PkgInfo/README.md index 08fe7b1..720f857 100644 --- a/PkgInfo/README.md +++ b/PkgInfo/README.md @@ -1,6 +1,5 @@ Fetches package information from the repositories of various \*nix distributions. Currently it supports: - Arch Linux -- CentOS (via a separate `centos` command) - Debian - Fedora - FreeBSD @@ -86,19 +85,6 @@ The `pkgsearch` command provides package searches on various distros. This suppo Found 55 results: cosmic/universe (1:6.0.3-0ubuntu1 [amd64, i386]), cosmic (1:6.0.3-0ubuntu1 [source]), bionic/universe (1:6.0.3-0ubuntu1 [amd64, i386]), bionic (1:6.0.3-0ubuntu1 [source]), artful-updates/universe (1:5.4.6-0ubuntu0.17.10.1 [amd64, i386]), artful-updates (1:5.4.6-0ubuntu0.17.10.1 [source]), artful-security/universe (1:5.4.5-0ubuntu0.17.10.5 [amd64, i386]), artful-security (7 more messages) ``` -### CentOS packages - -**Synopsis**: `centos [ ] [--arch ] [--startswith|--exact]` - -This lookup command is provided as a separate command due to very limited searching abilities through the CentOS website. - -``` - `centos 7 os zsh - Available RPMs: zsh-5.0.2-7.el7.x86_64.rpm and zsh-html-5.0.2-7.el7.x86_64.rpm - `centos 7 os python - Available RPMs: MySQL-python-1.2.3-11.el7.x86_64.rpm, OpenIPMI-python-2.0.19-11.el7.x86_64.rpm, abrt-addon-python-2.1.11-19.el7.centos.0.3.x86_64.rpm, abrt-python-2.1.11-19.el7.centos.0.3.x86_64.rpm, abrt-python-doc-2.1.11-19.el7.centos.0.3.noarch.rpm, antlr-python-2.7.7-30.el7.noarch.rpm, at-spi-python-1.32.0-12.el7.x86_64.rpm, audit-libs-python-2.4.1-5.el7.x86_64.rpm, (25 more messages) -``` - ## Implementation Details This plugin uses the following APIs: diff --git a/PkgInfo/plugin.py b/PkgInfo/plugin.py index e7b335a..42e0106 100644 --- a/PkgInfo/plugin.py +++ b/PkgInfo/plugin.py @@ -683,90 +683,6 @@ class PkgInfo(callbacks.Plugin): e = "No results found." irc.error(e) - @wrap(['positiveInt', additional('somethingWithoutSpaces'), additional('somethingWithoutSpaces'), - getopts({'arch': 'somethingWithoutSpaces', 'exact': '', 'startswith': ''})]) - def centos(self, irc, msg, args, release, repo, query, opts): - """ [ ] [--arch ] [--startswith|--exact] - - Looks up in CentOS's repositories. is the release - version (6, 7, etc.), and is the repository name. - You can find a list of possible repository names here: - http://mirror.centos.org/centos/7/ (each folder is a repository). - - Supported values for include x86_64 and i386 (prior to CentOS 7), - and defaults to x86_64. - - If is not given, a list of available ones will be shown instead. - - If --startswith is given, results starting with the given query are shown. If --exact - is given, only exact matches are shown.""" - - # TL;DR CentOS doesn't have a package lookup interface, but only an autoindexed - # file server... We must find all repositories, package URLs, etc. that way. - opts = dict(opts) - exact = opts.get('exact') - startswith = opts.get('startswith') - arch = opts.get('arch') or 'x86_64' - - url = 'http://mirror.centos.org/centos/%s' % release - if repo: - if query: - query = query.lower() - # Both repo and package name were given, so look in folders there. - # Note: different CentOS versions different paths for their pool, ugh. - for folder in ('Packages', 'RPMS', 'openstack-juno', 'openstack-kilo', - 'CentOS'): - url = 'http://mirror.centos.org/centos/%s/%s/%s/%s/' % \ - (release, repo, arch, folder) - self.log.debug("PkgInfo: trying url %s for 'centos' command", url) - try: - fd = utils.web.getUrl(url).decode("utf-8") - except utils.web.Error: - continue - else: - break - else: - irc.error('Unknown repository %r.' % repo, Raise=True) - else: - # Giving a repository but no package name is useless. Usually there - # are too many results to display without filtering anyways. - irc.error("Missing package query.", Raise=True) - else: # No repository given; list the ones available. - fd = utils.web.getUrl(url).decode("utf-8") - - soup = BeautifulSoup(fd) - # The first two tables are for the navigation bar; the third is the actual autoindex - # content. - res = [] - packagetable = soup.find_all('table')[2] - - for tr in packagetable.find_all('tr')[3:]: - try: - entry = tr.find_all('td')[1].a.text - except IndexError: - continue - - entry = entry.lower() - if not query: # No query filter given; show everything. - res.append(entry) - elif exact: # Match a package name in the format 'name'-version - package_pattern = '^{}-[0-9]+'.format(query) - if re.search(package_pattern, entry): - res.append(entry) - continue - elif startswith: - if entry.startswith(query): # startswith() match - res.append(entry) - continue - elif query in entry: # Default substring search - res.append(entry) - continue - - if res: - irc.reply(format('Found %n: %L; View more at: %u', (len(res), 'result'), res, url)) - else: - irc.error('No results found.') - Class = PkgInfo # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/PkgInfo/test.py b/PkgInfo/test.py index d0f8b50..264b7aa 100644 --- a/PkgInfo/test.py +++ b/PkgInfo/test.py @@ -1,5 +1,5 @@ ### -# Copyright (c) 2014-2017, James Lu +# Copyright (c) 2014-2019, James Lu # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -96,11 +96,4 @@ class PkgInfoTestCase(PluginTestCase): def test_filesearch(self): self.assertRegexp('filesearch sid supybot', 'limnoria') - def test_centos(self): - self.assertRegexp('centos 7 os git-', 'git-all') - self.assertRegexp('centos 6 os bash --arch i386', 'i686.rpm') - self.assertNotError('centos 7 extras python') - # This should be stripped. - self.assertNotRegexp('centos 7 extras "a"', 'Parent Directory') - # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: