Big rename and split into python modules

Ignore-this: 68006fd9b6602ad039904427e7b33daf
* Rename the supybot plugin: MeetBot -> Meeting
* Split the non-supybot specif parts into the `ircmeeting` Python
  module.
* Code changes to support these changes.
* This is a big change so it's expected to be a little bit messy.
  This patch may depend on others until things get sorted out.

darcs-hash:20101129040316-82ea9-e8ce7671c5b765551b98444dc082a9be6011dc4f.gz
This commit is contained in:
Richard Darst 2010-11-28 20:03:16 -08:00
parent 2ce038ee34
commit 7c094f8ef8
15 changed files with 51 additions and 31 deletions

View File

@ -36,7 +36,7 @@ import supybot.callbacks as callbacks
import supybot.ircmsgs as ircmsgs
import time
import meeting
import ircmeeting.meeting as meeting
import supybotconfig
# Because of the way we override names, we need to reload these in order.
meeting = reload(meeting)
@ -55,12 +55,12 @@ try: recent_meetings
except NameError: recent_meetings = [ ]
class MeetBot(callbacks.Plugin):
"""Add the help for "@plugin help MeetBot" here
class Meeting(callbacks.Plugin):
"""Add the help for "@plugin help Meeting" here
This should describe *how* to use this plugin."""
def __init__(self, irc):
self.__parent = super(MeetBot, self)
self.__parent = super(Meeting, self)
self.__parent.__init__(irc)
# Instead of using real supybot commands, I just listen to ALL
@ -294,9 +294,9 @@ class MeetBot(callbacks.Plugin):
# command (it does check more than I'd like). Heavy Wizardry.
instancemethod = type(self.__getattr__)
wrapped_function = wrap(wrapped_function, [optional('text', '')])
return instancemethod(wrapped_function, self, MeetBot)
return instancemethod(wrapped_function, self, Meeting)
Class = MeetBot
Class = Meeting
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:

View File

@ -35,11 +35,11 @@ import types
import supybot.conf as conf
import supybot.registry as registry
import meeting
import writers
import ircmeeting.meeting as meeting
import ircmeeting.writers as writers
# The plugin group for configuration
MeetBotConfigGroup = conf.registerPlugin('MeetBot')
MeetBotConfigGroup = conf.registerPlugin('Meeting')
class WriterMap(registry.String):
"""List of output formats to write. This is a space-separated

View File

@ -33,13 +33,12 @@ from supybot.test import *
import os
import sys
class MeetBotTestCase(ChannelPluginTestCase):
class MeetingTestCase(ChannelPluginTestCase):
channel = "#testchannel"
plugins = ('MeetBot',)
plugins = ('Meeting',)
def testRunMeeting(self):
test_script = file(os.path.join(os.path.dirname(__file__),
"tests/test-script-2.log.txt"))
test_script = file(os.path.join("test-script-2.log.txt"))
for line in test_script:
# Normalize input lines somewhat.
line = line.strip()

0
ircmeeting/__init__.py Normal file
View File

View File

@ -235,6 +235,22 @@ class Config(object):
f.flush()
newmode = os.stat(f.name).st_mode & (~self.RestrictPerm)
os.chmod(f.name, newmode)
def findFile(self, fname):
"""Find template files by searching paths.
Expand '+' prefix to the base data directory.
"""
# If `template` begins in '+', then it in relative to the
# MeetBot source directory.
if fname[0] == '+':
basedir = os.path.dirname(__file__)
fname = os.path.join(basedir, fname[1:])
# If we don't test here, it might fail in the try: block
# below, then f.close() will fail and mask the original
# exception
if not os.access(fname, os.F_OK):
raise IOError('File not found: %s'%fname)
return fname

View File

@ -271,16 +271,6 @@ class Template(_BaseWriter):
def format(self, extension=None, template='+template.html'):
repl = self.get_template2()
# If `template` begins in '+', then it in relative to the
# MeetBot source directory.
if template[0] == '+':
template = os.path.join(os.path.dirname(__file__), template[1:])
# If we don't test here, it might fail in the try: block
# below, then f.close() will fail and mask the original
# exception
if not os.access(template, os.F_OK):
raise IOError('File not found: %s'%template)
# Do we want to use a text template or HTML ?
import genshi.template
if template[-4:] in ('.txt', '.rst'):
@ -288,6 +278,8 @@ class Template(_BaseWriter):
else:
Template = genshi.template.MarkupTemplate # HTML-like
template = self.M.config.findFile(template)
# Do the actual templating work
try:
f = open(template, 'r')
@ -313,10 +305,10 @@ class _CSSmanager(object):
return ''
elif cssfile in ('', 'default'):
# default CSS file
css_fname = os.path.join(os.path.dirname(__file__),
'css-'+name+'-default.css')
css_fname = '+css-'+name+'-default.css'
else:
css_fname = cssfile
css_fname = self.M.config.findFile(css_fname)
try:
# Stylesheet specified
if getattr(self.M.config, 'cssEmbed_'+name, True):

12
setup.py Normal file
View File

@ -0,0 +1,12 @@
from distutils.core import setup
setup(name='MeetBot',
description='IRC Meeting Helper',
version='0.1.4',
packages=['supybot.plugins.Meeting',
'ircmeeting'],
package_dir={'supybot.plugins.Meeting':'Meeting'},
package_data={'ircmeeting':['*.html', '*.txt', '*.css']},
author="Richard Darst",
author_email="rkd@zgib.net"
)

View File

@ -7,8 +7,8 @@ import tempfile
import unittest
os.environ['MEETBOT_RUNNING_TESTS'] = '1'
import meeting
import writers
import ircmeeting.meeting as meeting
import ircmeeting.writers as writers
running_tests = True
@ -25,8 +25,9 @@ class MeetBotTest(unittest.TestCase):
"""
sys.argv[1:] = ["replay", "test-script-1.log.txt"]
sys.path.insert(0, "..")
sys.path.insert(0, "../ircmeeting")
try:
execfile("../meeting.py", {})
execfile("../ircmeeting/meeting.py", {})
finally:
del sys.path[0]
@ -37,14 +38,14 @@ class MeetBotTest(unittest.TestCase):
doesn't have a useful status code, so I need to parse the
output.
"""
os.symlink("..", "MeetBot")
os.symlink("../Meeting", "Meeting")
try:
output = os.popen("supybot-test ./MeetBot 2>&1").read()
output = os.popen("supybot-test ./Meeting 2>&1").read()
print output
assert 'FAILED' not in output, "supybot-based tests failed."
assert '\nOK\n' in output, "supybot-based tests failed."
finally:
os.unlink("MeetBot")
os.unlink("Meeting")
trivial_contents = """
10:10:10 <x> #startmeeting