org.guifications.plugins.buildsystem_rewrite: 19c2939c357ae55c59d2dc9b5aa604603b7914a6

grim at guifications.org grim at guifications.org
Sat Mar 29 02:00:09 CDT 2008


-----------------------------------------------------------------
Revision: 19c2939c357ae55c59d2dc9b5aa604603b7914a6
Ancestor: aadb5b36b2c509098948f1c1ba52a67838026d45
Author: grim at guifications.org
Date: 2008-03-29T06:59:26
Branch: org.guifications.plugins.buildsystem_rewrite

Added files:
        dice/plugins.ini flip/plugins.ini pluginpack.py
Modified attrs:
        pluginpack.py

ChangeLog: 

Initial work on the build system rewrite


-----------------------------------------------------------------
This revision's diffstat output:
 dice/plugins.ini |   10 ++++++++
 flip/plugins.ini |   10 ++++++++
 pluginpack.py    |   67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 87 insertions(+)
-------------- next part --------------
============================================================
--- dice/plugins.ini	d50ae624d9102eb159bdc9518e11708ac480ffb8
+++ dice/plugins.ini	d50ae624d9102eb159bdc9518e11708ac480ffb8
@@ -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
+
============================================================
--- flip/plugins.ini	8060c4c2db450b0833f6c9a195366dbec6604e5c
+++ flip/plugins.ini	8060c4c2db450b0833f6c9a195366dbec6604e5c
@@ -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
+
============================================================
--- pluginpack.py	d8bb341a5e8c7ca404ddbecb23aff8310af729ce
+++ pluginpack.py	d8bb341a5e8c7ca404ddbecb23aff8310af729ce
@@ -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()


More information about the Plugins-commits mailing list