[mod] searx.plugins.prepare_package_resources() - use generators

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2021-10-07 18:41:56 +02:00
parent aa5a5147b2
commit 5731b6b700
1 changed files with 11 additions and 17 deletions

View File

@ -59,7 +59,6 @@ def sync_resource(base_path, resource_path, name, target_dir, plugin_dir):
def prepare_package_resources(plugin, plugin_module_name):
# pylint: disable=consider-using-generator
plugin_base_path = dirname(abspath(plugin.__file__))
plugin_dir = plugin_module_name
@ -80,24 +79,19 @@ def prepare_package_resources(plugin, plugin_module_name):
if hasattr(plugin, "js_dependencies"):
resources.extend(map(basename, plugin.js_dependencies))
plugin.js_dependencies = tuple(
[
sync_resource(
plugin_base_path, x, plugin_module_name, target_dir, plugin_dir
)
for x in plugin.js_dependencies
]
)
plugin.js_dependencies = ([
sync_resource(
plugin_base_path, x, plugin_module_name, target_dir, plugin_dir
) for x in plugin.js_dependencies
])
if hasattr(plugin, "css_dependencies"):
resources.extend(map(basename, plugin.css_dependencies))
plugin.css_dependencies = tuple(
[
sync_resource(
plugin_base_path, x, plugin_module_name, target_dir, plugin_dir
)
for x in plugin.css_dependencies
]
)
plugin.css_dependencies = ([
sync_resource(
plugin_base_path, x, plugin_module_name, target_dir, plugin_dir
) for x in plugin.css_dependencies
])
for f in listdir(target_dir):
if basename(f) not in resources: