Update of /cvsroot/freevo/freevo/src
In directory sc8-pr-cvs1:/tmp/cvs-serv7166
Modified Files:
plugin.py
Log Message:
Rewrote the function to find the plugins to make it more generic
Index: plugin.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/plugin.py,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** plugin.py 19 Oct 2003 14:03:25 -0000 1.46
--- plugin.py 27 Oct 2003 20:09:38 -0000 1.47
***************
*** 10,13 ****
--- 10,16 ----
# -----------------------------------------------------------------------
# $Log$
+ # Revision 1.47 2003/10/27 20:09:38 dischi
+ # Rewrote the function to find the plugins to make it more generic
+ #
# Revision 1.46 2003/10/19 14:03:25 dischi
# external i18n support for plugins
***************
*** 393,396 ****
--- 396,432 ----
+ def __find_plugin_file__(filename):
+ global __plugin_basedir__
+ full_filename = os.path.join(__plugin_basedir__, filename)
+
+ if os.path.isfile(full_filename + '.py'):
+ return filename.replace('/', '.'), None
+
+ if os.path.isdir(full_filename):
+ return filename.replace('/', '.'), None
+
+ full_filename = os.path.join(__plugin_basedir__, 'plugins', filename)
+
+ if os.path.isfile(full_filename + '.py'):
+ return 'plugins.' + filename.replace('/', '.'), None
+
+ if os.path.isdir(full_filename):
+ return 'plugins.' + filename.replace('/', '.'), None
+
+ if filename.find('/') > 0:
+ special = filename[:filename.find('/')]
+ filename = os.path.join(special, 'plugins', filename[filename.find('/')+1:])
+ full_filename = os.path.join(__plugin_basedir__, filename)
+
+ if os.path.isfile(full_filename + '.py'):
+ return filename.replace('/', '.'), special
+
+ if os.path.isdir(full_filename):
+ return filename.replace('/', '.'), special
+
+ return None, None
+
+
+
def __load_plugin__(name, type, level, args, number):
"""
***************
*** 401,432 ****
global __plugin_basedir__
! module = name[:name.rfind('.')]
! # locate the plugin
! if os.path.isfile(os.path.join(__plugin_basedir__, 'plugins/%s.py' % module)):
! module = 'plugins.%s' % module
! object = 'plugins.%s' % name
! special = None
! elif os.path.isfile(os.path.join(__plugin_basedir__, 'plugins/%s.py' % name)):
! module = 'plugins.%s' % name
! object = 'plugins.%s.PluginInterface' % name
! special = None
! elif os.path.isfile(os.path.join(__plugin_basedir__, '%s/plugins/%s.py' % \
! (module, name[name.rfind('.')+1:]))):
! special = module
! module = '%s.plugins.%s' % (module, name[name.rfind('.')+1:])
! object = '%s.PluginInterface' % module
! elif os.path.isdir(os.path.join(__plugin_basedir__, '%s' % name)):
! module = name
! object = '%s.PluginInterface' % module
! special = None
! else:
! module = name
! object = '%s.PluginInterface' % module
! special = None
try:
if DEBUG:
! print 'loading %s as plugin %s' % (module, name)
exec('import %s' % module)
--- 437,467 ----
global __plugin_basedir__
! # fallback
! module = name
! object = '%s.PluginInterface' % module
! special = None
! # locate the plugin:
! files = []
+ module, special = __find_plugin_file__(name.replace('.', '/'))
+ if module:
+ object = module + '.PluginInterface'
+ elif name.find('.') > 0:
+ module, special = __find_plugin_file__(name[:name.rfind('.')].replace('.',
'/'))
+ if module:
+ object = module + '.%s' % name[name.rfind('.')+1:]
+ else:
+ print 'can\'t locate plugin %s' % name
+ print 'start \'freevo plugins -l\' to get a list of plugins'
+ return
+ else:
+ print 'can\'t locate plugin %s' % name
+ print 'start \'freevo plugins -l\' to get a list of plugins'
+ return
+
try:
if DEBUG:
! print 'loading %s as plugin %s' % (module, object)
exec('import %s' % module)
***************
*** 486,489 ****
--- 521,525 ----
except:
print 'failed to load plugin %s' % name
+ print 'start \'freevo plugins -l\' to get a list of plugins'
traceback.print_exc()
-------------------------------------------------------
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community? Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog