Commits

Jason R. Coombs  committed d852f80

Moved popquotes to its own package so pmxbot can be leaner.

  • Participants
  • Parent commits 00fc2c8
  • Tags 1100.4

Comments (0)

Files changed (6)

File pmxbot/pmxbot.py

 from . import util
 from . import saysomething as saysomethinglib
 from .cleanhtml import plaintext
-from . import popquotes
 
 log = logging.getLogger(__name__)
 

File pmxbot/popquotes/__init__.py

-"""
-Popular Quotes Database
-"""
-
-import itertools
-
-import pkg_resources
-
-from ..botbase import command
-from ..util import SQLiteQuotes
-
-db_file = pkg_resources.resource_filename('pmxbot.popquotes', 'popquotes.sqlite')
-
-def bartletts(lib, nick, qsearch):
-	qs = SQLiteQuotes.from_URI('sqlite:' + db_file)
-	qs.lib = lib
-	qsearch = qsearch.strip()
-	if nick == 'pmxbot':
-		qt, i, n = qs.quoteLookup()
-		if qt:
-			if qt.find(':', 0, 15) > -1:
-				qt = qt.split(':', 1)[1].strip()
-			return qt
-	else:
-		qt, i, n = qs.quoteLookupWNum(qsearch)
-		if qt:
-			return u'(%s/%s): %s' % (i, n, qt)
-
-# declare all of the popquotes commands
-quote_libs = (
-	# name, aliases, doc, lib
-	('bender', ('bend',), 'Quote Bender, a la http://en.wikiquote.org/wiki/Futurama', 'bender'),
-	('zoidberg', ('zoid',), 'Quote Zoidberg, a la http://en.wikiquote.org/wiki/Futurama', 'zoid'),
-	('simpsons', ('simp',), 'Quote the Simpsons, a la http://snpp.com/', 'simpsons'),
-	('hal', ('2001',), 'HAL 9000', 'hal'),
-	('grail', (), 'I questing baby', 'grail'),
-	('anchorman', (), 'Quote Anchorman.', 'anchorman'),
-	('hangover', (), 'Quote hangover.', 'hangover'),
-	('R', ('r',), 'Quote the R mailing list', 'R'),
-)
-
-# create the popquotes commands per the declarations above
-def make_command(name, aliases, doc, lib):
-	cmd_func = lambda client, event, channel, nick, rest: bartletts(lib, nick, rest)
-	cmd_func = command(name, aliases=aliases, doc=doc)(cmd_func)
-	globals().update({name: cmd_func})
-list(itertools.starmap(make_command, quote_libs))

File pmxbot/popquotes/popquotes.sqlite

Binary file removed.
 		],
 	),
 	install_requires=[
+		"popquotes>=1.0",
 		"pyyaml",
 		"python-irclib>=0.4.8",
 		"httplib2",

File tests/unit/test_commands.py

 import datetime
 
 import pytest
+import popquotes.pmxbot
 
 from pmxbot import pmxbot
 from pmxbot import botbase
 		pmxbot.excuse(c, e, '#test', 'testrunner', '')
 
 	def test_popquotes(self):
-		res = pmxbot.popquotes.bender(c, e, '#test', 'testrunner', '')
+		popquotes.pmxbot.install_commands()
+		res = popquotes.pmxbot.bender(c, e, '#test', 'testrunner', '')
 		assert len(res) > 5

File tests/unit/test_popquotes.py

-import re
-
-from pmxbot import popquotes
-from pmxbot import botbase
-
-quote_pattern = re.compile('\(\d+/\d+\): .+')
-
-def test_bender():
-	res = popquotes.bartletts('bender', 'somenick', '')
-	assert res is not None
-	assert quote_pattern.match(res)
-
-def test_registered():
-	handlers = botbase._handler_registry
-	all_names = [handler[1] for handler in handlers]
-	assert 'bender' in all_names