General cleanup in the plugin manager.

svn: r10638
This commit is contained in:
Brian Matherly 2008-04-25 01:03:08 +00:00
parent 5218afd3ab
commit 141c38cde3

View File

@ -95,8 +95,6 @@ def load_plugins(direct):
responsible for registering itself in the correct manner. No attempt
is done in this routine to register the tasks. Returns True on error. """
global success_list, attempt_list, loaddir_list, failmsg_list
# if the directory does not exist, do nothing
if not os.path.isdir(direct):
return False # return value is True for error
@ -125,8 +123,8 @@ def load_plugins(direct):
attempt_list.append(filename)
plugin = match.groups()[0]
try:
a = __import__(plugin)
success_list.append((filename,a))
_module = __import__(plugin)
success_list.append((filename, _module))
except:
failmsg_list.append((filename, sys.exc_info()))
@ -139,7 +137,7 @@ def load_plugins(direct):
#-------------------------------------------------------------------------
def reload_plugins():
""" Reload previously loaded plugins """
global success_list, attempt_list, loaddir_list, failmsg_list
global failmsg_list
pymod = re.compile(r"^(.*)\.py$")
@ -172,9 +170,9 @@ def reload_plugins():
# For some strange reason second importing of a failed plugin
# results in success. Then reload reveals the actual error.
# Looks like a bug in Python.
a = __import__(plugin)
reload(a)
success_list.append((filename, a))
_module = __import__(plugin)
reload(_module)
success_list.append((filename, _module))
except:
failmsg_list.append((filename, sys.exc_info()))
@ -190,10 +188,10 @@ def reload_plugins():
attempt_list.append(filename)
plugin = match.groups()[0]
try:
a = __import__(plugin)
if a not in [plugin[1]
_module = __import__(plugin)
if _module not in [plugin[1]
for plugin in success_list]:
success_list.append((filename, a))
success_list.append((filename, _module))
except:
failmsg_list.append((filename, sys.exc_info()))
@ -202,7 +200,8 @@ def reload_plugins():
# Plugin registering
#
#-------------------------------------------------------------------------
def register_export(exportData, title, description='', config=None, filename=''):
def register_export(exportData, title, description='', config=None,
filename=''):
"""
Register an export filter, taking the task, file filter,
and the list of patterns for the filename matching.
@ -490,9 +489,6 @@ def register_quick_report(
The low-level functions (starting with '_') should not be used
on their own. Instead, this function will call them as needed.
"""
"""Register a report with the plugin system"""
global quick_report_list
del_index = -1
for i in range(0, len(quick_report_list)):
val = quick_report_list[i]
@ -567,16 +563,3 @@ def register_relcalc(relclass, languages):
def relationship_class():
global _relcalc_class
return _relcalc_class()
#-------------------------------------------------------------------------
#
# Image attributes
#
#-------------------------------------------------------------------------
_image_attributes = []
def register_image_attribute(name):
if name not in _image_attributes:
_image_attributes.append(name)
def get_image_attributes():
return _image_attributes