mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
fix path prefixes
This commit is contained in:
parent
e5d474fa0b
commit
38eaca1104
@ -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 = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user