Clean up the registry calls

This commit is contained in:
James Vega 2004-01-21 01:33:59 +00:00
parent e9f77d6ab0
commit 75b6da806e
3 changed files with 21 additions and 21 deletions

View File

@ -139,7 +139,7 @@ class Amazon(callbacks.Privmsg):
'%(publisher)s%(url)s' '%(publisher)s%(url)s'
try: try:
book = amazon.searchByKeyword(isbn) book = amazon.searchByKeyword(isbn)
bold = conf.supybot.plugins.Amazon.bold() bold = self.registryValue('bold', msg.args[0])
res = self._genResults(s, attribs, book, url, bold, 'title') res = self._genResults(s, attribs, book, url, bold, 'title')
if res: if res:
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
@ -172,7 +172,7 @@ class Amazon(callbacks.Privmsg):
'%(publisher)s%(url)s' '%(publisher)s%(url)s'
try: try:
books = amazon.searchByKeyword(keyword) books = amazon.searchByKeyword(keyword)
bold = conf.supybot.plugins.Amazon.bold() bold = self.registryValue('bold', msg.args[0])
res = self._genResults(s, attribs, books, url, bold, 'title') res = self._genResults(s, attribs, books, url, bold, 'title')
if res: if res:
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
@ -211,7 +211,7 @@ class Amazon(callbacks.Privmsg):
'%(date)s; published by %(publisher)s%(url)s' '%(date)s; published by %(publisher)s%(url)s'
try: try:
videos = amazon.searchByKeyword(keyword, product_line=product) videos = amazon.searchByKeyword(keyword, product_line=product)
bold = conf.supybot.plugins.Amazon.bold() bold = self.registryValue('bold', msg.args[0])
res = self._genResults(s, attribs, videos, url, bold, 'title') res = self._genResults(s, attribs, videos, url, bold, 'title')
if res: if res:
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
@ -242,7 +242,7 @@ class Amazon(callbacks.Privmsg):
s = '"%(title)s"%(url)s' s = '"%(title)s"%(url)s'
try: try:
item = amazon.searchByASIN(asin) item = amazon.searchByASIN(asin)
bold = conf.supybot.plugins.Amazon.bold() bold = self.registryValue('bold', msg.args[0])
res = self._genResults(s, attribs, item, url, bold, 'title') res = self._genResults(s, attribs, item, url, bold, 'title')
if res: if res:
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
@ -276,7 +276,7 @@ class Amazon(callbacks.Privmsg):
s = '"%(title)s" %(manufacturer)s%(url)s' s = '"%(title)s" %(manufacturer)s%(url)s'
try: try:
item = amazon.searchByUPC(upc) item = amazon.searchByUPC(upc)
bold = conf.supybot.plugins.Amazon.bold() bold = self.registryValue('bold', msg.args[0])
res = self._genResults(s, attribs, item, url, bold, 'title') res = self._genResults(s, attribs, item, url, bold, 'title')
if res: if res:
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
@ -309,7 +309,7 @@ class Amazon(callbacks.Privmsg):
'%(publisher)s%(url)s' '%(publisher)s%(url)s'
try: try:
books = amazon.searchByAuthor(author) books = amazon.searchByAuthor(author)
bold = conf.supybot.plugins.Amazon.bold() bold = self.registryValue('bold', msg.args[0])
res = self._genResults(s, attribs, books, url, bold, 'title') res = self._genResults(s, attribs, books, url, bold, 'title')
if res: if res:
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
@ -407,7 +407,7 @@ class Amazon(callbacks.Privmsg):
'%(publisher)s%(url)s' '%(publisher)s%(url)s'
try: try:
items = amazon.searchByArtist(artist, product_line=product) items = amazon.searchByArtist(artist, product_line=product)
bold = conf.supybot.plugins.Amazon.bold() bold = self.registryValue('bold', msg.args[0])
res = self._genResults(s, attribs, items, url, bold, 'title') res = self._genResults(s, attribs, items, url, bold, 'title')
if res: if res:
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
@ -447,7 +447,7 @@ class Amazon(callbacks.Privmsg):
'%(date)s; published by %(publisher)s%(url)s' '%(date)s; published by %(publisher)s%(url)s'
try: try:
items = amazon.searchByActor(actor, product_line=product) items = amazon.searchByActor(actor, product_line=product)
bold = conf.supybot.plugins.Amazon.bold() bold = self.registryValue('bold', msg.args[0])
res = self._genResults(s, attribs, items, url, bold, 'title') res = self._genResults(s, attribs, items, url, bold, 'title')
if res: if res:
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
@ -487,7 +487,7 @@ class Amazon(callbacks.Privmsg):
'%(date)s; published by %(publisher)s%(url)s' '%(date)s; published by %(publisher)s%(url)s'
try: try:
items = amazon.searchByDirector(director, product_line=product) items = amazon.searchByDirector(director, product_line=product)
bold = conf.supybot.plugins.Amazon.bold() bold = self.registryValue('bold', msg.args[0])
res = self._genResults(s, attribs, items, url, bold, 'title') res = self._genResults(s, attribs, items, url, bold, 'title')
if res: if res:
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
@ -526,7 +526,7 @@ class Amazon(callbacks.Privmsg):
try: try:
items = amazon.searchByManufacturer(manufacturer, items = amazon.searchByManufacturer(manufacturer,
product_line=product) product_line=product)
bold = conf.supybot.plugins.Amazon.bold() bold = self.registryValue('bold', msg.args[0])
res = self._genResults(s, attribs, items, url, bold, 'title') res = self._genResults(s, attribs, items, url, bold, 'title')
if res: if res:
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))

View File

@ -107,7 +107,7 @@ conf.registerChannelValue(conf.supybot.plugins.Bugzilla, 'bugSnarfer',
information reported into the channel.""")) information reported into the channel."""))
conf.registerChannelValue(conf.supybot.plugins.Bugzilla, 'bold', conf.registerChannelValue(conf.supybot.plugins.Bugzilla, 'bold',
registry.Boolean(True, """Determines whether results are bolded.""")) registry.Boolean(True, """Determines whether results are bolded."""))
conf.registerGlobalValue(conf.supybot.plugins.Bugzilla, 'replyNoBugzilla', conf.registerChannellValue(conf.supybot.plugins.Bugzilla, 'replyNoBugzilla',
registry.String('I don\'t have a bugzilla %r.', """Determines the phrase registry.String('I don\'t have a bugzilla %r.', """Determines the phrase
to use when notifying the user that there is no information about that to use when notifying the user that there is no information about that
bugzilla site.""")) bugzilla site."""))
@ -172,7 +172,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp):
self.shorthand = utils.abbrev(self.db.keys()) self.shorthand = utils.abbrev(self.db.keys())
irc.replySuccess() irc.replySuccess()
except KeyError: except KeyError:
s = conf.supybot.plugins.Bugzilla.replyNoBugzilla() s = self.registryValue('replyNoBugzilla', msg.args[0])
irc.error(s % name) irc.error(s % name)
def list(self, irc, msg, args): def list(self, irc, msg, args):
@ -188,7 +188,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp):
(url, description) = self.db[name] (url, description) = self.db[name]
irc.reply('%s: %s, %s' % (name, description, url)) irc.reply('%s: %s, %s' % (name, description, url))
except KeyError: except KeyError:
s = conf.supybot.plugins.Bugzilla.replyNoBugzilla() s = self.registryValue('replyNoBugzilla', msg.args[0])
irc.error(s % name) irc.error(s % name)
else: else:
if self.db: if self.db:
@ -200,7 +200,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp):
def bzSnarfer(self, irc, msg, match): def bzSnarfer(self, irc, msg, match):
r"(http://\S+)/show_bug.cgi\?id=([0-9]+)" r"(http://\S+)/show_bug.cgi\?id=([0-9]+)"
if not conf.supybot.plugins.Bugzilla.bugSnarfer(): if not self.registryValue('bugSnarfer', msg.args[0]):
return return
queryurl = '%s/xml.cgi?id=%s' % (match.group(1), match.group(2)) queryurl = '%s/xml.cgi?id=%s' % (match.group(1), match.group(2))
try: try:
@ -271,7 +271,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp):
name = self.shorthand[name] name = self.shorthand[name]
(url, description) = self.db[name] (url, description) = self.db[name]
except KeyError: except KeyError:
s = conf.supybot.plugins.Bugzilla.replyNoBugzilla() s = self.registryValue('replyNoBugzilla', msg.args[0])
irc.error(s % name) irc.error(s % name)
return return
bugs = self.urlquery2bugslist(url, query) bugs = self.urlquery2bugslist(url, query)
@ -292,7 +292,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp):
name = self.shorthand[name] name = self.shorthand[name]
(url, description) = self.db[name] (url, description) = self.db[name]
except KeyError: except KeyError:
s = conf.supybot.plugins.Bugzilla.replyNoBugzilla() s = self.registryValue('replyNoBugzilla', msg.args[0])
irc.error(s % name) irc.error(s % name)
return return
queryurl = '%s/xml.cgi?id=%s' % (url, number) queryurl = '%s/xml.cgi?id=%s' % (url, number)
@ -315,7 +315,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp):
def _mk_summary_string(self, summary): def _mk_summary_string(self, summary):
L = [] L = []
if conf.supybot.plugins.Bugzilla.bold(): if self.registryValue('bold', msg.args[0]):
decorate = lambda s: ircutils.bold(s) decorate = lambda s: ircutils.bold(s)
else: else:
decorate = lambda s: s decorate = lambda s: s

View File

@ -221,8 +221,8 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
except google.NoLicenseKey, e: except google.NoLicenseKey, e:
irc.error(str(e)) irc.error(str(e))
return return
bold = conf.supybot.plugins.Google.bold() bold = self.registryValue('bold', msg.args[0])
max = conf.supybot.plugins.Google.maximumResults() max = self.registryValue('maximumResults', msg.args[0])
irc.reply(self.formatData(data, bold=bold, max=max)) irc.reply(self.formatData(data, bold=bold, max=max))
def metagoogle(self, irc, msg, args): def metagoogle(self, irc, msg, args):
@ -302,7 +302,7 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
def googleSnarfer(self, irc, msg, match): def googleSnarfer(self, irc, msg, match):
r"^google\s+(.*)$" r"^google\s+(.*)$"
if not conf.supybot.plugins.Google.searchSnarfer(): if not self.registryValue('searchSnarfer', msg.args[0]):
return return
searchString = match.group(1) searchString = match.group(1)
try: try:
@ -322,7 +322,7 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
_ggPlainGroup = re.compile(r'Newsgroups: (.*)') _ggPlainGroup = re.compile(r'Newsgroups: (.*)')
def googleGroups(self, irc, msg, match): def googleGroups(self, irc, msg, match):
r"http://groups.google.com/[^\s]+" r"http://groups.google.com/[^\s]+"
if not conf.supybot.plugins.Google.groupsSnarfer(): if not self.registryValue('groupsSnarfer', msg.args[0]):
return return
request = urllib2.Request(match.group(0), headers= \ request = urllib2.Request(match.group(0), headers= \
{'User-agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)'}) {'User-agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)'})