fix path prefixes

This commit is contained in:
Matthias 2021-11-22 00:48:46 +01:00
parent e5d474fa0b
commit 38eaca1104
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -35,7 +35,19 @@ def get_plugin_error(error, do_raise: bool = False, do_log: bool = False, log_na
try: try:
package_name = pathlib.Path(package_path).relative_to(install_path).parts[0] package_name = pathlib.Path(package_path).relative_to(install_path).parts[0]
except ValueError: except ValueError:
package_name = pathlib.Path(package_path).relative_to(settings.BASE_DIR) # is file - loaded -> form a name for that
path_obj = pathlib.Path(package_path).relative_to(settings.BASE_DIR)
path_parts = [*path_obj.parts]
path_parts[-1] = path_parts[-1].replace(path_obj.suffix, '') # remove suffix
# remove path preixes
if path_parts[0] == 'plugin':
path_parts.remove('plugin')
path_parts.pop(0)
else:
path_parts.remove('plugins')
package_name = '.'.join(path_parts)
if do_log: if do_log:
log_kwargs = {} log_kwargs = {}