pidgin/purple-plugin-pack

Initial work on the build system rewrite
org.guifications.plugins.buildsystem_rewrite
2008-03-29, grim
356d5b55486e
Parents 60b780ac903c
Children 244e5dec1104
Initial work on the build system rewrite
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dice/plugins.ini Sat Mar 29 06:59:26 2008 -0400
@@ -0,0 +1,10 @@
+[plugins]
+sections=dice
+
+[dice]
+name=Dice
+type=default
+dependencies=purple
+summary=Rolls dice in a chat or im
+description=Adds a command (/dice) to roll an arbitrary number of dice with an arbitrary number of sides. Now supports dice notation! /help dice for details
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/flip/plugins.ini Sat Mar 29 06:59:26 2008 -0400
@@ -0,0 +1,10 @@
+[plugins]
+sections=flip
+
+[flip]
+name=Coin Flip
+type=default
+dependencies=purple
+summary=Flips a coin and outputs the result
+description=Adds a command (/flip) to flip a coin and outputs the result in the active conversation
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pluginpack.py Sat Mar 29 06:59:26 2008 -0400
@@ -0,0 +1,67 @@
+#!/usr/bin/python
+
+import ConfigParser
+import glob
+import os.path
+import sys
+
+plugins = []
+
+class Plugin:
+ name = ''
+ summary = ''
+ description = ''
+ directory = ''
+ dependencies = []
+ type = ''
+
+ def __init__(self, directory, name, parser):
+ self.directory = directory
+
+ self.name = parser.get(name, 'name')
+ self.summary = parser.get(name, 'summary')
+ self.description = parser.get(name, 'description')
+ self.dependencies = parser.get(name, 'dependencies').split()
+ self.type = parser.get(name, 'type')
+
+ def __str__(self):
+ return '[name=\'%s\', directory=\'%s\']' % (self.name, self.directory)
+
+def printerr(msg):
+ print >> sys.stderr, msg
+
+def load_plugins():
+ for file in glob.glob('*/plugins.ini'):
+ parser = ConfigParser.ConfigParser()
+
+ try:
+ parser.read(file)
+ except ConfigParser.ParsingError, msg:
+ printerr('Failed to parse \'%s\':\n%s' % (file, msg))
+ continue
+
+ if not parser.has_section('plugins'):
+ printerr('\'%s\' does not have a plugins section!' % file)
+ continue
+
+ if not parser.has_option('plugins', 'sections'):
+ printerr('\'%s\' does not have a sections option under the plugins section' % file)
+ continue
+
+ for plugin in parser.get('plugins', 'sections').split():
+ if not parser.has_section(plugin):
+ printerr('\'%s\' does not have a section named \'%s\'!' % (file, plugin))
+ continue
+
+ p = Plugin(os.path.dirname(file), plugin, parser)
+
+ plugins.append(p)
+
+def main():
+ load_plugins()
+
+ for p in plugins:
+ print p
+
+if __name__ == "__main__":
+ main()