Tidy up dict iter access

master
Tom Wilson 6 years ago
parent 6a06ba1fc2
commit 17225a1b39

@ -296,7 +296,7 @@ def load_plugin(plugin_name, plugin_dir=None):
# Scan module for load markers left by decorators # Scan module for load markers left by decorators
for name, attr in module.__dict__.items(): for attr in module.__dict__.values():
if hasattr(attr, "_shepherd_load_marker"): if hasattr(attr, "_shepherd_load_marker"):
if isinstance(attr._shepherd_load_marker, FunctionMarker): if isinstance(attr._shepherd_load_marker, FunctionMarker):
interface.register_function(attr, **attr._shepherd_load_marker._asdict()) interface.register_function(attr, **attr._shepherd_load_marker._asdict())
@ -305,7 +305,7 @@ def load_plugin(plugin_name, plugin_dir=None):
if interface._plugin_class is not None: if interface._plugin_class is not None:
# Scan plugin class for marked methods # Scan plugin class for marked methods
for name, attr in interface._plugin_class.__dict__.items(): for attr in interface._plugin_class.__dict__.values():
if hasattr(attr, "_shepherd_load_marker"): if hasattr(attr, "_shepherd_load_marker"):
if isinstance(attr._shepherd_load_marker, FunctionMarker): if isinstance(attr._shepherd_load_marker, FunctionMarker):
# Instance doesn't exist yet, so need to save unbound methods for binding later # Instance doesn't exist yet, so need to save unbound methods for binding later
@ -339,7 +339,7 @@ def init_plugins(plugin_configs, core_config):
# If it has one, instantiate the plugin object and bind functions # If it has one, instantiate the plugin object and bind functions
if interface._plugin_class is not None: if interface._plugin_class is not None:
interface._plugin_obj = interface._plugin_class() interface._plugin_obj = interface._plugin_class()
for funcname, ifunc in interface._functions.items(): for ifunc in interface._functions.values():
if ifunc._unbound: if ifunc._unbound:
ifunc._bind(interface._plugin_obj) ifunc._bind(interface._plugin_obj)

Loading…
Cancel
Save