General cleanup in the plugin manager.
svn: r10638
This commit is contained in:
parent
5218afd3ab
commit
141c38cde3
@ -95,8 +95,6 @@ def load_plugins(direct):
|
|||||||
responsible for registering itself in the correct manner. No attempt
|
responsible for registering itself in the correct manner. No attempt
|
||||||
is done in this routine to register the tasks. Returns True on error. """
|
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 the directory does not exist, do nothing
|
||||||
if not os.path.isdir(direct):
|
if not os.path.isdir(direct):
|
||||||
return False # return value is True for error
|
return False # return value is True for error
|
||||||
@ -125,8 +123,8 @@ def load_plugins(direct):
|
|||||||
attempt_list.append(filename)
|
attempt_list.append(filename)
|
||||||
plugin = match.groups()[0]
|
plugin = match.groups()[0]
|
||||||
try:
|
try:
|
||||||
a = __import__(plugin)
|
_module = __import__(plugin)
|
||||||
success_list.append((filename,a))
|
success_list.append((filename, _module))
|
||||||
except:
|
except:
|
||||||
failmsg_list.append((filename, sys.exc_info()))
|
failmsg_list.append((filename, sys.exc_info()))
|
||||||
|
|
||||||
@ -139,7 +137,7 @@ def load_plugins(direct):
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def reload_plugins():
|
def reload_plugins():
|
||||||
""" Reload previously loaded plugins """
|
""" Reload previously loaded plugins """
|
||||||
global success_list, attempt_list, loaddir_list, failmsg_list
|
global failmsg_list
|
||||||
|
|
||||||
pymod = re.compile(r"^(.*)\.py$")
|
pymod = re.compile(r"^(.*)\.py$")
|
||||||
|
|
||||||
@ -172,9 +170,9 @@ def reload_plugins():
|
|||||||
# For some strange reason second importing of a failed plugin
|
# For some strange reason second importing of a failed plugin
|
||||||
# results in success. Then reload reveals the actual error.
|
# results in success. Then reload reveals the actual error.
|
||||||
# Looks like a bug in Python.
|
# Looks like a bug in Python.
|
||||||
a = __import__(plugin)
|
_module = __import__(plugin)
|
||||||
reload(a)
|
reload(_module)
|
||||||
success_list.append((filename, a))
|
success_list.append((filename, _module))
|
||||||
except:
|
except:
|
||||||
failmsg_list.append((filename, sys.exc_info()))
|
failmsg_list.append((filename, sys.exc_info()))
|
||||||
|
|
||||||
@ -190,10 +188,10 @@ def reload_plugins():
|
|||||||
attempt_list.append(filename)
|
attempt_list.append(filename)
|
||||||
plugin = match.groups()[0]
|
plugin = match.groups()[0]
|
||||||
try:
|
try:
|
||||||
a = __import__(plugin)
|
_module = __import__(plugin)
|
||||||
if a not in [plugin[1]
|
if _module not in [plugin[1]
|
||||||
for plugin in success_list]:
|
for plugin in success_list]:
|
||||||
success_list.append((filename, a))
|
success_list.append((filename, _module))
|
||||||
except:
|
except:
|
||||||
failmsg_list.append((filename, sys.exc_info()))
|
failmsg_list.append((filename, sys.exc_info()))
|
||||||
|
|
||||||
@ -202,7 +200,8 @@ def reload_plugins():
|
|||||||
# Plugin registering
|
# 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,
|
Register an export filter, taking the task, file filter,
|
||||||
and the list of patterns for the filename matching.
|
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
|
The low-level functions (starting with '_') should not be used
|
||||||
on their own. Instead, this function will call them as needed.
|
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
|
del_index = -1
|
||||||
for i in range(0, len(quick_report_list)):
|
for i in range(0, len(quick_report_list)):
|
||||||
val = quick_report_list[i]
|
val = quick_report_list[i]
|
||||||
@ -567,16 +563,3 @@ def register_relcalc(relclass, languages):
|
|||||||
def relationship_class():
|
def relationship_class():
|
||||||
global _relcalc_class
|
global _relcalc_class
|
||||||
return _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
|
|
||||||
|
Loading…
Reference in New Issue
Block a user