Skip to content

Commit

Permalink
Split scan_for_plugins() in two
Browse files Browse the repository at this point in the history
Chiefly, this will help setting up tests.
  • Loading branch information
Lord-Kamina committed Jul 16, 2024
1 parent 1d6f667 commit a30f669
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions deluge/pluginmanagerbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def get_enabled_plugins(self):
"""Returns a list of enabled plugins"""
return list(self.plugins)

def scan_for_plugins(self):
"""Scans for available plugins"""
def get_plugin_dirs(self):
"""Returns a list comprising plugin folders, as well as plugin wheels and eggs"""
base_dir = deluge.common.resource_filename('deluge', 'plugins')
user_dir = os.path.join(deluge.configmanager.get_config_dir(), 'plugins')
base_subdir = [
Expand All @@ -107,14 +107,18 @@ def scan_for_plugins(self):
if os.path.isdir(os.path.join(base_dir, f))
]
plugin_dirs = [base_dir, user_dir] + base_subdir

plugin_wheels = list(Path(base_dir).glob('*.whl'))
plugin_wheels.extend(list(Path(user_dir).glob('*.whl')))
plugin_eggs = list(Path(base_dir).glob('*.egg'))
plugin_eggs.extend(list(Path(user_dir).glob('*.egg')))

plugin_dirs = [str(f) for f in plugin_wheels + plugin_eggs if os.path.isfile(f)]
plugin_dirs.extend([base_dir, user_dir] + base_subdir)
return plugin_dirs

def scan_for_plugins(self):
"""Scans for available plugins"""
plugin_dirs = self.get_plugin_dirs()
[sys.path.append(item) for item in plugin_dirs if item not in sys.path]
plugin_eps = entry_points(group=self.entry_name)
self.available_plugins = []
Expand Down

0 comments on commit a30f669

Please sign in to comment.