diff --git a/__init__.py b/Meeting/__init__.py similarity index 100% rename from __init__.py rename to Meeting/__init__.py diff --git a/config.py b/Meeting/config.py similarity index 100% rename from config.py rename to Meeting/config.py diff --git a/plugin.py b/Meeting/plugin.py similarity index 97% rename from plugin.py rename to Meeting/plugin.py index ace7efd..9e02508 100644 --- a/plugin.py +++ b/Meeting/plugin.py @@ -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: diff --git a/supybotconfig.py b/Meeting/supybotconfig.py similarity index 98% rename from supybotconfig.py rename to Meeting/supybotconfig.py index f846b4d..485a738 100644 --- a/supybotconfig.py +++ b/Meeting/supybotconfig.py @@ -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 diff --git a/test.py b/Meeting/test.py similarity index 94% rename from test.py rename to Meeting/test.py index b739fbc..40d93be 100644 --- a/test.py +++ b/Meeting/test.py @@ -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() diff --git a/ircmeeting/__init__.py b/ircmeeting/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/css-log-default.css b/ircmeeting/css-log-default.css similarity index 100% rename from css-log-default.css rename to ircmeeting/css-log-default.css diff --git a/css-minutes-default.css b/ircmeeting/css-minutes-default.css similarity index 100% rename from css-minutes-default.css rename to ircmeeting/css-minutes-default.css diff --git a/items.py b/ircmeeting/items.py similarity index 100% rename from items.py rename to ircmeeting/items.py diff --git a/meeting.py b/ircmeeting/meeting.py similarity index 97% rename from meeting.py rename to ircmeeting/meeting.py index 9a11c9f..9204204 100644 --- a/meeting.py +++ b/ircmeeting/meeting.py @@ -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 diff --git a/template.html b/ircmeeting/template.html similarity index 100% rename from template.html rename to ircmeeting/template.html diff --git a/template.txt b/ircmeeting/template.txt similarity index 100% rename from template.txt rename to ircmeeting/template.txt diff --git a/writers.py b/ircmeeting/writers.py similarity index 98% rename from writers.py rename to ircmeeting/writers.py index 7a6738b..7787235 100644 --- a/writers.py +++ b/ircmeeting/writers.py @@ -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): diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..494705e --- /dev/null +++ b/setup.py @@ -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" + ) diff --git a/tests/run_test.py b/tests/run_test.py index 07aecdf..2455b7d 100644 --- a/tests/run_test.py +++ b/tests/run_test.py @@ -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 #startmeeting