mirror of
https://github.com/wassname/scikit-image.git
synced 2026-09-12 12:50:49 +08:00
COSMIT pep8
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
|
||||
__all__ = ['use', 'available', 'call', 'info', 'configuration', 'reset_plugins']
|
||||
|
||||
import warnings
|
||||
from ConfigParser import ConfigParser
|
||||
import os.path
|
||||
from glob import glob
|
||||
@@ -15,8 +14,9 @@ plugin_provides = {}
|
||||
plugin_module_name = {}
|
||||
plugin_meta_data = {}
|
||||
|
||||
|
||||
def reset_plugins():
|
||||
"""Clear the plugin state to the default, i.e., where no plugins are loaded.
|
||||
"""Clear the plugin state to the default, i.e., where no plugins are loaded
|
||||
|
||||
"""
|
||||
global plugin_store
|
||||
@@ -28,6 +28,7 @@ def reset_plugins():
|
||||
|
||||
reset_plugins()
|
||||
|
||||
|
||||
def _scan_plugins():
|
||||
"""Scan the plugins directory for .ini files and parse them
|
||||
to gather plugin meta-data.
|
||||
@@ -59,6 +60,7 @@ def _scan_plugins():
|
||||
|
||||
_scan_plugins()
|
||||
|
||||
|
||||
def call(kind, *args, **kwargs):
|
||||
"""Find the appropriate plugin of 'kind' and execute it.
|
||||
|
||||
@@ -90,13 +92,14 @@ command. A list of all available plugins can be found using
|
||||
else:
|
||||
_load(plugin)
|
||||
try:
|
||||
func = [f for (p,f) in plugin_funcs if p == plugin][0]
|
||||
func = [f for (p, f) in plugin_funcs if p == plugin][0]
|
||||
except IndexError:
|
||||
raise RuntimeError('Could not find the plugin "%s" for %s.' % \
|
||||
(plugin, kind))
|
||||
|
||||
return func(*args, **kwargs)
|
||||
|
||||
|
||||
def use(name, kind=None):
|
||||
"""Set the default plugin for a specified operation. The plugin
|
||||
will be loaded if it hasn't been already.
|
||||
@@ -149,6 +152,7 @@ def use(name, kind=None):
|
||||
|
||||
plugin_store[k] = funcs
|
||||
|
||||
|
||||
def available(loaded=False):
|
||||
"""List available plugins.
|
||||
|
||||
@@ -178,6 +182,7 @@ def available(loaded=False):
|
||||
|
||||
return d
|
||||
|
||||
|
||||
def _load(plugin):
|
||||
"""Load the given plugin.
|
||||
|
||||
@@ -211,6 +216,7 @@ def _load(plugin):
|
||||
if not (plugin, func) in store:
|
||||
store.append((plugin, func))
|
||||
|
||||
|
||||
def info(plugin):
|
||||
"""Return plugin meta-data.
|
||||
|
||||
@@ -230,6 +236,7 @@ def info(plugin):
|
||||
except KeyError:
|
||||
raise ValueError('No information on plugin "%s"' % plugin)
|
||||
|
||||
|
||||
def configuration():
|
||||
"""Return the currently preferred plugin order.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user