Skip to content

Commit

Permalink
Improve method and variable naming
Browse files Browse the repository at this point in the history
  • Loading branch information
papr committed May 19, 2020
1 parent af6d49c commit 1ebe8ec
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pupil_src/shared_modules/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,13 @@ def __iter__(self):
def __str__(self):
return "Plugin List: {}".format(self._plugins)

def add(self, new_plugin, args={}):
def add(self, new_plugin_cls, args={}):
"""
add a plugin instance to the list.
"""
self._avoid_duplication(new_plugin)
self._find_and_remove_duplicates(new_plugin_cls)

plugin_instance = new_plugin(self.g_pool, **args)
plugin_instance = new_plugin_cls(self.g_pool, **args)
if not plugin_instance.alive:
logger.warning("plugin failed to initialize")
return
Expand All @@ -367,9 +367,9 @@ def add(self, new_plugin, args={}):
if self.g_pool.app in ("capture", "player"):
plugin_instance.init_ui()

def _avoid_duplication(self, new_plugin_cls):
def _find_and_remove_duplicates(self, new_plugin_cls):
for duplicate in self._duplicates(new_plugin_cls):
self._remove_duplicate(duplicate)
self._remove_duplicated_instance(duplicate)

def _duplicates(self, new_plugin_cls):
if new_plugin_cls.uniqueness == "by_base_class":
Expand All @@ -387,7 +387,7 @@ def _duplicates_by_rule(self, is_duplicate_rule, new_plugin_cls):
)
yield from duplicates

def _remove_duplicate(self, duplicated_plugin_inst):
def _remove_duplicated_instance(self, duplicated_plugin_inst):
name = duplicated_plugin_inst.pretty_class_name
uniq = duplicated_plugin_inst.uniqueness
message = f"Replacing {name} due to '{uniq}' uniqueness"
Expand Down

0 comments on commit 1ebe8ec

Please sign in to comment.