mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-23 10:34:19 +01:00
Getoptified debincoming.
This commit is contained in:
parent
ff2e043f00
commit
cbc109ada9
@ -38,6 +38,7 @@ from baseplugin import *
|
|||||||
import re
|
import re
|
||||||
import gzip
|
import gzip
|
||||||
import sets
|
import sets
|
||||||
|
import getopt
|
||||||
import popen2
|
import popen2
|
||||||
import random
|
import random
|
||||||
import fnmatch
|
import fnmatch
|
||||||
@ -204,20 +205,41 @@ class Debian(callbacks.Privmsg, PeriodicFileDownloader):
|
|||||||
(numberOfPackages, len(responses), ', '.join(responses))
|
(numberOfPackages, len(responses), ', '.join(responses))
|
||||||
irc.reply(msg, s)
|
irc.reply(msg, s)
|
||||||
|
|
||||||
_incomingRe = re.compile(r'<a href="(.*?)\.deb">', re.I)
|
_incomingRe = re.compile(r'<a href="(.*?\.deb)">', re.I)
|
||||||
def debincoming(self, irc, msg, args):
|
def debincoming(self, irc, msg, args):
|
||||||
"""<package name>
|
"""[--{regexp,arch}=<value>] [<glob>]
|
||||||
|
|
||||||
checks debian incoming for specified package name"""
|
Checks debian incoming for a matching package name. The arch
|
||||||
pkgname = privmsgs.getArgs(args)
|
parameter defaults to i386; --regexp returns only those package names
|
||||||
|
that match a given regexp, and normal matches use standard *nix
|
||||||
|
globbing.
|
||||||
|
"""
|
||||||
|
(optlist, rest) = getopt.getopt(args, '', ['regexp=', 'arch='])
|
||||||
|
predicates = []
|
||||||
|
archPredicate = lambda s: ('_i386.' in s)
|
||||||
|
for (option, arg) in optlist:
|
||||||
|
if option == '--regexp':
|
||||||
|
try:
|
||||||
|
r = utils.perlReToPythonRe(arg)
|
||||||
|
predicates.append(r.search)
|
||||||
|
except ValueError:
|
||||||
|
irc.error('%r is not a valid regexp.' % arg)
|
||||||
|
return
|
||||||
|
elif option == '--arch':
|
||||||
|
arg = '_%s.' % arg
|
||||||
|
archPredicate = lambda s, arg=arg: (arg in s)
|
||||||
|
predicates.append(archPredicate)
|
||||||
|
for arg in rest:
|
||||||
|
predicates.append(lambda s: fnmatch.fnmatch(s, arg))
|
||||||
packages = []
|
packages = []
|
||||||
fd = urllib2.urlopen('http://incoming.debian.org/')
|
fd = urllib2.urlopen('http://incoming.debian.org/')
|
||||||
for line in fd:
|
for line in fd:
|
||||||
m = self._incomingRe.search(line)
|
m = self._incomingRe.search(line)
|
||||||
if m:
|
if m:
|
||||||
name = m.group(1)
|
name = m.group(1)
|
||||||
if fnmatch.fnmatch(name, pkgname):
|
if all(lambda p: p(name), predicates):
|
||||||
packages.append(name)
|
realname = utils.rsplit(name, '_', 1)[0]
|
||||||
|
packages.append(realname)
|
||||||
if len(packages) == 0:
|
if len(packages) == 0:
|
||||||
irc.error(msg, 'No packages matched that search.')
|
irc.error(msg, 'No packages matched that search.')
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user