Skip to content

Commit

Permalink
module_loader: extension_name clearer and works with variable extensi…
Browse files Browse the repository at this point in the history
…on path
  • Loading branch information
dale-wahl committed Feb 13, 2025
1 parent 410195c commit 2bc6a55
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions common/lib/module_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def load_modules(self):
# determine module name for file
# reduce path to be relative to 4CAT root
module_name = ".".join(file.parts[len(root_path.parts):-1] + (file.stem,))
extension_name = file.parts[len(extension_path.parts):][0] if is_extension else None

# check if we've already loaded this module
if module_name in self.ignore:
Expand All @@ -125,7 +126,7 @@ def load_modules(self):
# This skips processors/datasources that were loaded by others and may not yet be captured
pass

if is_extension and len(module_name.split(".")) > 1 and module_name.split(".")[1] not in enabled_extensions:
if is_extension and len(module_name.split(".")) > 1 and extension_name not in enabled_extensions:
continue

# try importing
Expand Down Expand Up @@ -157,7 +158,7 @@ def load_modules(self):
self.workers[component[1].type].filepath = relative_path
self.workers[component[1].type].is_extension = is_extension
if is_extension:
self.workers[component[1].type].extension_name = module_name.split(".")[1]
self.workers[component[1].type].extension_name = extension_name

# we can't use issubclass() because for that we would need
# to import BasicProcessor, which would lead to a circular
Expand Down

0 comments on commit 2bc6a55

Please sign in to comment.