Update to work with registry changes and add 'deprecated' warnings.

This commit is contained in:
James Vega 2004-02-09 05:06:20 +00:00
parent 08158cafcb
commit f2bb0c0125

View File

@ -29,8 +29,6 @@
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
### ###
import supybot
import os import os
import cgi import cgi
import imp import imp
@ -39,11 +37,24 @@ import os.path
import textwrap import textwrap
import traceback import traceback
import conf import supybot
conf.dataDir = 'test-data'
conf.confDir = 'test-conf'
conf.logDir = 'test-log'
if not os.path.exists('test-conf'):
os.mkdir('test-conf')
registryFilename = os.path.join('test-conf', 'test.conf')
fd = file(registryFilename, 'w')
fd.write("""
supybot.directories.data: test-data
supybot.directories.conf: test-conf
supybot.directories.log: test-logs
""")
fd.close()
import registry
registry.open(registryFilename)
import conf
import utils import utils
import callbacks import callbacks
@ -141,6 +152,15 @@ def makePluginDocumentation(pluginWindow):
trClasses = { 'even':'odd', 'odd':'even' } trClasses = { 'even':'odd', 'odd':'even' }
trClass = 'even' trClass = 'even'
(pluginName, module, plugin) = pluginWindow[1] (pluginName, module, plugin) = pluginWindow[1]
if getattr(module, "deprecated", False):
deprecated = textwrap.dedent("""
<div class="deprecated">This plugin is deprecated. That means that it
is probably broken and no one cares about it enought to fix it or the
3rd party module it may be using. If you want this plugin to work,
adopt it or provide a patch in our patch tracker on Sourceforge.</div>
""")
else:
deprecated = ''
print 'Generating documentation for %s.py' % pluginName print 'Generating documentation for %s.py' % pluginName
prev = pluginWindow[0][0] or '../plugins' prev = pluginWindow[0][0] or '../plugins'
next = pluginWindow[2][0] or '../plugins' next = pluginWindow[2][0] or '../plugins'
@ -169,11 +189,13 @@ def makePluginDocumentation(pluginWindow):
<div class="plugintitle">%s</div> <div class="plugintitle">%s</div>
%s %s
<div class="mainbody" style="padding: 0;"> <div class="mainbody" style="padding: 0;">
%s
<table> <table>
<tr id="trheader"><td>Command</td><td>Args</td><td> <tr id="trheader"><td>Command</td><td>Args</td><td>
Detailed Help</td></tr> Detailed Help</td></tr>
''' % (genHeader(title, meta), ''' % (genHeader(title, meta),
cgi.escape(module.__doc__ or ""), cgi.escape(module.__doc__ or ""),
deprecated,
genNavbar('../../')))) genNavbar('../../'))))
attrs = [x for x in dir(plugin) if plugin.isCommand(x) and not attrs = [x for x in dir(plugin) if plugin.isCommand(x) and not
x.startswith('_')] x.startswith('_')]
@ -270,11 +292,13 @@ def makeCommandsIndex():
fd.close() fd.close()
def genPlugins(): def genPlugins():
for directory in conf.pluginDirs: for directory in conf.supybot.directories.plugins():
for filename in os.listdir(directory): for filename in os.listdir(directory):
if filename.endswith('.py') and filename[0].isupper(): if filename.endswith('.py') and filename[0].isupper():
pluginName = filename.split('.')[0] pluginName = filename.split('.')[0]
moduleInfo = imp.find_module(pluginName, conf.pluginDirs) moduleInfo = imp.find_module(pluginName,
conf.supybot.directories.plugins()
)
module = imp.load_module(pluginName, *moduleInfo) module = imp.load_module(pluginName, *moduleInfo)
if not hasattr(module, 'Class'): if not hasattr(module, 'Class'):
print '%s is not a plugin.' % filename print '%s is not a plugin.' % filename
@ -290,12 +314,12 @@ def genPlugins():
yield (pluginName, module, plugin) yield (pluginName, module, plugin)
if __name__ == '__main__': if __name__ == '__main__':
if not os.path.exists(conf.dataDir): if not os.path.exists(conf.supybot.directories.data()):
os.mkdir(conf.dataDir) os.mkdir(conf.supybot.directories.data())
if not os.path.exists(conf.confDir): if not os.path.exists(conf.supybot.directories.conf()):
os.mkdir(conf.confDir) os.mkdir(conf.supybot.directories.conf())
if not os.path.exists(conf.logDir): if not os.path.exists(conf.supybot.directories.log()):
os.mkdir(conf.logDir) os.mkdir(conf.supybot.directories.log())
prepIndex() prepIndex()
plugins = [p for p in genPlugins()] plugins = [p for p in genPlugins()]
plugins.sort() plugins.sort()