Code: Alles auswählen
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import sys, os, glob
print __name__
this_path = os.path.dirname(__file__)
class PluginManager:
def __init__(self):
self.plugin_data = {}
def load_plugins(self):
'''
load all plugins
'''
files = glob.glob(os.path.join(this_path,'*.py'))
files += glob.glob(os.path.join(this_path,'*.pyw'))
for path in files:
filename = os.path.basename(path)
print filename
if filename.startswith('_'):
# Module mit underline sind "private"
continue
plugin_name = os.path.splitext(filename)[0]
# Infromation's Dict aus plugin holen
self.plugin_data[plugin_name] = __import__(__name__,globals(), locals(), [plugin_name,])
######################################################
def __getitem__( self, key ):
return self.plugin_data[key]
def iteritems( self ):
return self.plugin_data.iteritems()
def has_key( self, key ):
return self.plugin_data.has_key( key )
def __str__( self ):
return str( self.plugin_data )
######################################################
def debug( self ):
for plugin_name,plugin in self.plugin_data.iteritems():
print plugin_name
print dir(plugin)
for section, value in plugin.plugin_info.iteritems():
print "\t%s - %s" % (section,value)
print "-"*80
if __name__ == "__main__":
mm = PluginManager()
mm.load_plugins()
mm.debug()