summaryrefslogtreecommitdiff
path: root/plugins/__init__.py
blob: d83b441f7c55909f52662741cbbdff9b8a831735 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
def listPlugins():
	global _plugins
	return _plugins

_plugins=[]
import os
for file in os.listdir('plugins'):
	if file[-3:]=='.py' and file!='__init__.py':
		name=file[:-3]	# name without ext
		pkg='plugins.%s'%(name)	# pkg name
		pluginName='plugin%s'%(name)	# classname
		
		module=__import__(pkg, globals(), locals(), pluginName, -1)
		try:
			# check here if the file contains an entity (let's hope
			# a class!) with $pluginName!
			module.__dict__[pluginName]
			_plugins.append([pkg, pluginName])
		except:
			#print "Failed to load plugin "+pluginName
			pass