mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-05-03 08:51:13 -05:00
PkgInfo: Handle 'too many results' errors in pkgsearch and cap archaur at 150 results (Closes #14)
This commit is contained in:
parent
544b90ab7e
commit
e110bca89b
@ -178,11 +178,11 @@ class PkgInfo(callbacks.Plugin):
|
|||||||
if count:
|
if count:
|
||||||
# We want this to be limited to prevent overflow warnings
|
# We want this to be limited to prevent overflow warnings
|
||||||
# in the bot.
|
# in the bot.
|
||||||
if count > 240:
|
if count > 150:
|
||||||
count = '240+'
|
count = '150+'
|
||||||
s = "Found {} result{}: ".format(count,
|
s = "Found {} result{}: ".format(count,
|
||||||
's' if data["resultcount"] != 1 else '')
|
's' if data["resultcount"] != 1 else '')
|
||||||
for x in data['results'][:240]:
|
for x in data['results'][:150]:
|
||||||
verboseInfo = ''
|
verboseInfo = ''
|
||||||
if self.registryValue("verbose"):
|
if self.registryValue("verbose"):
|
||||||
verboseInfo = " [ID:{} Votes:{}]".format(x['ID'], x['NumVotes'])
|
verboseInfo = " [ID:{} Votes:{}]".format(x['ID'], x['NumVotes'])
|
||||||
@ -200,8 +200,9 @@ class PkgInfo(callbacks.Plugin):
|
|||||||
irc.error("This command requires the Beautiful Soup 4 library. See"
|
irc.error("This command requires the Beautiful Soup 4 library. See"
|
||||||
" https://github.com/GLolol/SupyPlugins/blob/master/README.md"
|
" https://github.com/GLolol/SupyPlugins/blob/master/README.md"
|
||||||
"#pkginfo for instructions on how to install it.", Raise=True)
|
"#pkginfo for instructions on how to install it.", Raise=True)
|
||||||
|
distro = distro.lower()
|
||||||
try:
|
try:
|
||||||
url = '%ssearch?keywords=%s' % (self.addrs[distro.lower()], quote(query))
|
url = '%ssearch?keywords=%s' % (self.addrs[distro], quote(query))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.error('Unknown distribution.', Raise=True)
|
irc.error('Unknown distribution.', Raise=True)
|
||||||
try:
|
try:
|
||||||
@ -216,7 +217,14 @@ class PkgInfo(callbacks.Plugin):
|
|||||||
utils.str.commaAndify(results), url)
|
utils.str.commaAndify(results), url)
|
||||||
irc.reply(s)
|
irc.reply(s)
|
||||||
else:
|
else:
|
||||||
irc.error("No results found.")
|
if distro == "debian":
|
||||||
|
errorParse = soup.find("div", class_="note")
|
||||||
|
errorParse = errorParse.p
|
||||||
|
else:
|
||||||
|
errorParse = soup.find("p", attrs={"id": "psearchtoomanyhits"})
|
||||||
|
for e in errorParse.findAll('br'):
|
||||||
|
e.replace_with(" ")
|
||||||
|
irc.error(errorParse.text.strip() or "No results found.")
|
||||||
pkgsearch = wrap(pkgsearch, ['somethingWithoutSpaces', 'somethingWithoutSpaces'])
|
pkgsearch = wrap(pkgsearch, ['somethingWithoutSpaces', 'somethingWithoutSpaces'])
|
||||||
|
|
||||||
def mintpkg(self, irc, msg, args, release, query, opts):
|
def mintpkg(self, irc, msg, args, release, query, opts):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user