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:
parent
2ce038ee34
commit
7c094f8ef8
@ -36,7 +36,7 @@ import supybot.callbacks as callbacks
|
|||||||
import supybot.ircmsgs as ircmsgs
|
import supybot.ircmsgs as ircmsgs
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import meeting
|
import ircmeeting.meeting as meeting
|
||||||
import supybotconfig
|
import supybotconfig
|
||||||
# Because of the way we override names, we need to reload these in order.
|
# Because of the way we override names, we need to reload these in order.
|
||||||
meeting = reload(meeting)
|
meeting = reload(meeting)
|
||||||
@ -55,12 +55,12 @@ try: recent_meetings
|
|||||||
except NameError: recent_meetings = [ ]
|
except NameError: recent_meetings = [ ]
|
||||||
|
|
||||||
|
|
||||||
class MeetBot(callbacks.Plugin):
|
class Meeting(callbacks.Plugin):
|
||||||
"""Add the help for "@plugin help MeetBot" here
|
"""Add the help for "@plugin help Meeting" here
|
||||||
This should describe *how* to use this plugin."""
|
This should describe *how* to use this plugin."""
|
||||||
|
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(MeetBot, self)
|
self.__parent = super(Meeting, self)
|
||||||
self.__parent.__init__(irc)
|
self.__parent.__init__(irc)
|
||||||
|
|
||||||
# Instead of using real supybot commands, I just listen to ALL
|
# 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.
|
# command (it does check more than I'd like). Heavy Wizardry.
|
||||||
instancemethod = type(self.__getattr__)
|
instancemethod = type(self.__getattr__)
|
||||||
wrapped_function = wrap(wrapped_function, [optional('text', '')])
|
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:
|
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -35,11 +35,11 @@ import types
|
|||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import supybot.registry as registry
|
import supybot.registry as registry
|
||||||
|
|
||||||
import meeting
|
import ircmeeting.meeting as meeting
|
||||||
import writers
|
import ircmeeting.writers as writers
|
||||||
|
|
||||||
# The plugin group for configuration
|
# The plugin group for configuration
|
||||||
MeetBotConfigGroup = conf.registerPlugin('MeetBot')
|
MeetBotConfigGroup = conf.registerPlugin('Meeting')
|
||||||
|
|
||||||
class WriterMap(registry.String):
|
class WriterMap(registry.String):
|
||||||
"""List of output formats to write. This is a space-separated
|
"""List of output formats to write. This is a space-separated
|
@ -33,13 +33,12 @@ from supybot.test import *
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
class MeetBotTestCase(ChannelPluginTestCase):
|
class MeetingTestCase(ChannelPluginTestCase):
|
||||||
channel = "#testchannel"
|
channel = "#testchannel"
|
||||||
plugins = ('MeetBot',)
|
plugins = ('Meeting',)
|
||||||
|
|
||||||
def testRunMeeting(self):
|
def testRunMeeting(self):
|
||||||
test_script = file(os.path.join(os.path.dirname(__file__),
|
test_script = file(os.path.join("test-script-2.log.txt"))
|
||||||
"tests/test-script-2.log.txt"))
|
|
||||||
for line in test_script:
|
for line in test_script:
|
||||||
# Normalize input lines somewhat.
|
# Normalize input lines somewhat.
|
||||||
line = line.strip()
|
line = line.strip()
|
0
ircmeeting/__init__.py
Normal file
0
ircmeeting/__init__.py
Normal file
@ -235,6 +235,22 @@ class Config(object):
|
|||||||
f.flush()
|
f.flush()
|
||||||
newmode = os.stat(f.name).st_mode & (~self.RestrictPerm)
|
newmode = os.stat(f.name).st_mode & (~self.RestrictPerm)
|
||||||
os.chmod(f.name, newmode)
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -271,16 +271,6 @@ class Template(_BaseWriter):
|
|||||||
def format(self, extension=None, template='+template.html'):
|
def format(self, extension=None, template='+template.html'):
|
||||||
repl = self.get_template2()
|
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 ?
|
# Do we want to use a text template or HTML ?
|
||||||
import genshi.template
|
import genshi.template
|
||||||
if template[-4:] in ('.txt', '.rst'):
|
if template[-4:] in ('.txt', '.rst'):
|
||||||
@ -288,6 +278,8 @@ class Template(_BaseWriter):
|
|||||||
else:
|
else:
|
||||||
Template = genshi.template.MarkupTemplate # HTML-like
|
Template = genshi.template.MarkupTemplate # HTML-like
|
||||||
|
|
||||||
|
template = self.M.config.findFile(template)
|
||||||
|
|
||||||
# Do the actual templating work
|
# Do the actual templating work
|
||||||
try:
|
try:
|
||||||
f = open(template, 'r')
|
f = open(template, 'r')
|
||||||
@ -313,10 +305,10 @@ class _CSSmanager(object):
|
|||||||
return ''
|
return ''
|
||||||
elif cssfile in ('', 'default'):
|
elif cssfile in ('', 'default'):
|
||||||
# default CSS file
|
# default CSS file
|
||||||
css_fname = os.path.join(os.path.dirname(__file__),
|
css_fname = '+css-'+name+'-default.css'
|
||||||
'css-'+name+'-default.css')
|
|
||||||
else:
|
else:
|
||||||
css_fname = cssfile
|
css_fname = cssfile
|
||||||
|
css_fname = self.M.config.findFile(css_fname)
|
||||||
try:
|
try:
|
||||||
# Stylesheet specified
|
# Stylesheet specified
|
||||||
if getattr(self.M.config, 'cssEmbed_'+name, True):
|
if getattr(self.M.config, 'cssEmbed_'+name, True):
|
12
setup.py
Normal file
12
setup.py
Normal 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"
|
||||||
|
)
|
@ -7,8 +7,8 @@ import tempfile
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
os.environ['MEETBOT_RUNNING_TESTS'] = '1'
|
os.environ['MEETBOT_RUNNING_TESTS'] = '1'
|
||||||
import meeting
|
import ircmeeting.meeting as meeting
|
||||||
import writers
|
import ircmeeting.writers as writers
|
||||||
|
|
||||||
running_tests = True
|
running_tests = True
|
||||||
|
|
||||||
@ -25,8 +25,9 @@ class MeetBotTest(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
sys.argv[1:] = ["replay", "test-script-1.log.txt"]
|
sys.argv[1:] = ["replay", "test-script-1.log.txt"]
|
||||||
sys.path.insert(0, "..")
|
sys.path.insert(0, "..")
|
||||||
|
sys.path.insert(0, "../ircmeeting")
|
||||||
try:
|
try:
|
||||||
execfile("../meeting.py", {})
|
execfile("../ircmeeting/meeting.py", {})
|
||||||
finally:
|
finally:
|
||||||
del sys.path[0]
|
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
|
doesn't have a useful status code, so I need to parse the
|
||||||
output.
|
output.
|
||||||
"""
|
"""
|
||||||
os.symlink("..", "MeetBot")
|
os.symlink("../Meeting", "Meeting")
|
||||||
try:
|
try:
|
||||||
output = os.popen("supybot-test ./MeetBot 2>&1").read()
|
output = os.popen("supybot-test ./Meeting 2>&1").read()
|
||||||
print output
|
print output
|
||||||
assert 'FAILED' not in output, "supybot-based tests failed."
|
assert 'FAILED' not in output, "supybot-based tests failed."
|
||||||
assert '\nOK\n' in output, "supybot-based tests failed."
|
assert '\nOK\n' in output, "supybot-based tests failed."
|
||||||
finally:
|
finally:
|
||||||
os.unlink("MeetBot")
|
os.unlink("Meeting")
|
||||||
|
|
||||||
trivial_contents = """
|
trivial_contents = """
|
||||||
10:10:10 <x> #startmeeting
|
10:10:10 <x> #startmeeting
|
||||||
|
Loading…
x
Reference in New Issue
Block a user