PackageInfo: Add 'releases' command to list all valid releases.
* Instead no longer include those in error message on invalid releases. * But add setting to send list of valid releases in private on error. * Minor fixes to Encyclopedia along the way. * Update default configuration.
This commit is contained in:
@ -24,7 +24,7 @@ import supybot
|
||||
import supybot.world as world
|
||||
from importlib import reload
|
||||
|
||||
__version__ = "3.5.1"
|
||||
__version__ = "3.5.2"
|
||||
__author__ = supybot.Author("Krytarik Raido", "krytarik", "krytarik@gmail.com")
|
||||
__contributors__ = {
|
||||
supybot.Author("Dennis Kaarsemaker", "Seveas", "dennis@kaarsemaker.net"): ['Original Author'],
|
||||
|
@ -204,7 +204,7 @@ class Encyclopedia(callbacks.Plugin):
|
||||
remove = wrap(remove, ['otherUser'])
|
||||
|
||||
def editors(self, irc, msg, args):
|
||||
"""Takes no arguments
|
||||
"""takes no arguments
|
||||
|
||||
Lists all the users who are in the list of editors.
|
||||
"""
|
||||
@ -212,7 +212,7 @@ class Encyclopedia(callbacks.Plugin):
|
||||
editors = wrap(editors)
|
||||
|
||||
def moderators(self, irc, msg, args):
|
||||
"""Takes no arguments
|
||||
"""takes no arguments
|
||||
|
||||
Lists all the users who can add users to the list of editors.
|
||||
"""
|
||||
|
@ -107,6 +107,3 @@ class EncyclopediaTestCase(ChannelPluginTestCase):
|
||||
'In test, user said: test-#ubuntu-se is <reply> blah')
|
||||
finally:
|
||||
world.testing = True
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 tabstop=4 expandtab textwidth=100:
|
||||
|
@ -22,7 +22,7 @@ import supybot
|
||||
import supybot.world as world
|
||||
from importlib import reload
|
||||
|
||||
__version__ = "2.1.1"
|
||||
__version__ = "2.2.0"
|
||||
__author__ = supybot.Author("Krytarik Raido", "krytarik", "krytarik@gmail.com")
|
||||
__contributors__ = {
|
||||
supybot.Author("Dennis Kaarsemaker", "Seveas", "dennis@kaarsemaker.net"): ['Original Concept'],
|
||||
@ -44,6 +44,3 @@ if world.testing:
|
||||
|
||||
Class = plugin.Class
|
||||
configure = config.configure
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||
|
@ -38,8 +38,7 @@ deb-src deb http://security.debian.org/ %s/updates main contrib non-free
|
||||
""" % (release, release)
|
||||
|
||||
from supybot.questions import output, expect, something, yn
|
||||
import subprocess
|
||||
import os
|
||||
import os, subprocess
|
||||
|
||||
def anything(prompt, default=None):
|
||||
"""Because supybot is pure fail"""
|
||||
@ -71,7 +70,7 @@ deb-src deb http://security.debian.org/ %s/updates main contrib non-free
|
||||
PackageInfo.prefixchar.setValue(prefixchar)
|
||||
PackageInfo.defaultRelease.setValue(defaultRelease)
|
||||
|
||||
default_dists = set(['precise', 'trusty', 'xenial', 'yakkety', 'zesty', 'artful',
|
||||
default_dists = set(['bionic', 'focal', 'groovy', 'hirsute', 'impish',
|
||||
'oldstable', 'stable', 'unstable', 'testing', 'experimental'])
|
||||
pluginDir = os.path.abspath(os.path.dirname(__file__))
|
||||
update_apt = os.path.join(pluginDir, 'update_apt')
|
||||
@ -127,13 +126,18 @@ deb-src deb http://security.debian.org/ %s/updates main contrib non-free
|
||||
output("You need to install apt-file in order to use the !find command of this plugin")
|
||||
|
||||
PackageInfo = conf.registerPlugin('PackageInfo')
|
||||
|
||||
conf.registerChannelValue(PackageInfo, 'enabled',
|
||||
registry.Boolean(True, "Enable package lookup"))
|
||||
|
||||
conf.registerChannelValue(PackageInfo, 'prefixchar',
|
||||
conf.ValidPrefixChars('!', "Character the bot will respond to"))
|
||||
|
||||
conf.registerChannelValue(PackageInfo, 'defaultRelease',
|
||||
registry.String('zesty', "Default release to use when none is specified"))
|
||||
registry.String('hirsute', "Default release to use when none is specified"))
|
||||
|
||||
conf.registerChannelValue(PackageInfo, 'listReleasesOnError',
|
||||
registry.Boolean(True, "Send list of all valid releases in private on error"))
|
||||
|
||||
conf.registerGlobalValue(PackageInfo, 'aptdir',
|
||||
conf.Directory(conf.supybot.directories.data.dirize('aptdir'), "Path to the apt directory", private=True))
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||
|
@ -73,9 +73,6 @@ class Apt:
|
||||
return parser.close()
|
||||
|
||||
def find(self, pkg, distro, filelookup=True):
|
||||
if distro not in self.distros:
|
||||
return "%r is not a valid release: %s" % (distro, ", ".join(self.distros))
|
||||
|
||||
if distro.split('-')[0] in ('oldstable', 'stable', 'unstable', 'testing', 'experimental'):
|
||||
pkgTracURL = "https://packages.debian.org"
|
||||
else:
|
||||
@ -108,9 +105,6 @@ class Apt:
|
||||
return "Found: %s" % ', '.join(pkgs)
|
||||
|
||||
def raw_info(self, pkg, distro, isSource, archlookup=True):
|
||||
if distro not in self.distros:
|
||||
return "%r is not a valid release: %s" % (distro, ", ".join(self.distros))
|
||||
|
||||
try:
|
||||
data = self.apt_cache(distro, ['show'] if not isSource else ['showsrc', '--only-source'], pkg)
|
||||
except subprocess.CalledProcessError:
|
||||
|
@ -147,6 +147,11 @@ class PackageInfo(callbacks.Plugin):
|
||||
(release, rest) = self.__getRelease(irc, release, channel)
|
||||
if not release:
|
||||
return
|
||||
if release not in self.Apt.distros:
|
||||
irc.reply("%r is not a valid release" % release)
|
||||
if self.registryValue("listReleasesOnError", channel, irc.network):
|
||||
irc.reply("Valid releases are: %s" % ', '.join(self.Apt.distros), private=True)
|
||||
return
|
||||
(package, isSource) = self.__getPackage(package)
|
||||
target = ircutils.replyTo(msg)
|
||||
reply = self.Apt.info(package, release, isSource)
|
||||
@ -166,6 +171,11 @@ class PackageInfo(callbacks.Plugin):
|
||||
(release, rest) = self.__getRelease(irc, release, channel)
|
||||
if not release:
|
||||
return
|
||||
if release not in self.Apt.distros:
|
||||
irc.reply("%r is not a valid release" % release)
|
||||
if self.registryValue("listReleasesOnError", channel, irc.network):
|
||||
irc.reply("Valid releases are: %s" % ', '.join(self.Apt.distros), private=True)
|
||||
return
|
||||
(package, isSource) = self.__getPackage(package)
|
||||
target = ircutils.replyTo(msg)
|
||||
reply = self.Apt.depends(package, release, isSource)
|
||||
@ -186,6 +196,11 @@ class PackageInfo(callbacks.Plugin):
|
||||
(release, rest) = self.__getRelease(irc, release, channel)
|
||||
if not release:
|
||||
return
|
||||
if release not in self.Apt.distros:
|
||||
irc.reply("%r is not a valid release" % release)
|
||||
if self.registryValue("listReleasesOnError", channel, irc.network):
|
||||
irc.reply("Valid releases are: %s" % ', '.join(self.Apt.distros), private=True)
|
||||
return
|
||||
target = ircutils.replyTo(msg)
|
||||
reply = self.Apt.find(package, release)
|
||||
if rest:
|
||||
@ -193,6 +208,14 @@ class PackageInfo(callbacks.Plugin):
|
||||
queue(irc, target, reply)
|
||||
find = wrap(find, ['anything', optional('text')])
|
||||
|
||||
def releases(self, irc, msg, args):
|
||||
"""takes no arguments
|
||||
|
||||
List all valid releases.
|
||||
"""
|
||||
irc.reply("Valid releases are: %s" % ', '.join(self.Apt.distros))
|
||||
releases = wrap(releases)
|
||||
|
||||
def doPrivmsg(self, irc, msg):
|
||||
if chr(1) in msg.args[1]: # CTCP
|
||||
return
|
||||
@ -229,6 +252,3 @@ class PackageInfo(callbacks.Plugin):
|
||||
return msg
|
||||
|
||||
Class = PackageInfo
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||
|
@ -17,6 +17,3 @@ from supybot.test import *
|
||||
|
||||
class PackageInfoTestCase(PluginTestCase):
|
||||
plugins = ('PackageInfo',)
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||
|
Reference in New Issue
Block a user