From 5d5c353f1c9a66064bb4914ab405b8f50d21572b Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sun, 20 Jun 2021 16:19:20 -0400 Subject: SlackTools: rename pkgsrc => srcsearch, add pkg -s option --- SlackTools/plugin.py | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'SlackTools') diff --git a/SlackTools/plugin.py b/SlackTools/plugin.py index c4b0e7d..f6c0484 100644 --- a/SlackTools/plugin.py +++ b/SlackTools/plugin.py @@ -164,19 +164,28 @@ class SlackTools(callbacks.Plugin): filesearch = thread(wrap(filesearch, ['somethingWithoutSpaces'])) # run filesearch or pkgsearch, save some typing. - def pkg(self, irc, msg, args, fileflag, term): - """ [-f] + def pkg(self, irc, msg, args, flag, term): + """ [-f|-s] - Without -f, same as pkgsearch. With -f, same as filesearch. - See the help for pkgsearch and/or filesearch for details. + Without no argument, same as pkgsearch. With -f, same as filesearch. + With -s, same as srcsearch. + See the help for pkgsearch, filesearch, srcsearch for details. """ - if(fileflag): + if(term is None): + term = flag + flag = '-p' + + if(flag == '-f'): self.PkgQuery(irc, msg, 'file', term) - else: + elif(flag == '-p'): self.PkgQuery(irc, msg, 'pkg', term) + elif(flag == '-s'): + self.PkgSrc(irc, msg, args, term) + else: + irc.error("invalid option '" + flag + "'") - pkg = thread(wrap(pkg, [optional(('literal', ['-f'])), 'somethingWithoutSpaces'])) + pkg = thread(wrap(pkg, ['somethingWithoutSpaces', optional('somethingWithoutSpaces')])) def FileQuery(self, irc, msg, term): db = self.InitDB(); @@ -258,24 +267,26 @@ class SlackTools(callbacks.Plugin): return None + def PkgSrc(self, irc, msg, args, pkg): + url = self.FindSrc(pkg) + if (url is None): + irc.reply("no source found for " + pkg) + else: + irc.reply(url) + # fun fact: there's no source dir for the kernel-source package! # if there's not an individual source dir for an x11/ package, # we get source/x/x11/ as the result. That's where x11.SlackBuild # lives, so it's correct. - def pkgsrc(self, irc, msg, args, pkg): + def srcsearch(self, irc, msg, args, pkg): """ Find the URL for the source directory of a Slackware package. This is the directory containing the SlackBuild. The package name is searched for first in patches/, and then the main slackware64/. """ + self.PkgSrc(irc, msg, args, pkg) - url = self.FindSrc(pkg) - if (url is None): - irc.reply("no source found for " + pkg) - else: - irc.reply(url) - - pkgsrc = thread(wrap(pkgsrc, ['somethingWithoutSpaces'])) + srcsearch = thread(wrap(srcsearch, ['somethingWithoutSpaces'])) Class = SlackTools -- cgit v1.2.3