From 38eaca1104f1f920df4ff5b1d5f3c37cccda82ed Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 22 Nov 2021 00:48:46 +0100 Subject: [PATCH] fix path prefixes --- InvenTree/plugin/helpers.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/InvenTree/plugin/helpers.py b/InvenTree/plugin/helpers.py index 33259dadf4..0de0c0aaec 100644 --- a/InvenTree/plugin/helpers.py +++ b/InvenTree/plugin/helpers.py @@ -35,7 +35,19 @@ def get_plugin_error(error, do_raise: bool = False, do_log: bool = False, log_na try: package_name = pathlib.Path(package_path).relative_to(install_path).parts[0] 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: log_kwargs = {}