Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jbirddog committed Oct 9, 2024
1 parent 42d6385 commit 9676e1e
Showing 1 changed file with 3 additions and 30 deletions.
33 changes: 3 additions & 30 deletions src/spiffworkflow_proxy/plugin_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,48 +76,21 @@ def command_named(plugin_display_name: str, command_name: str) -> type[Connector
return available_commands_by_plugin[plugin_name][command_name]
except Exception:
return None

#
# commands True connector_example.commands
# combine_strings False connector_example.commands.combine_strings
# some_helper False connector_example.some_helper
#

@staticmethod
def modules_for_plugin_in_package2(
plugin: types.ModuleType, package_name: str | None
) -> Generator[tuple[str, types.ModuleType], None, None]:
for finder, name, ispkg in pkgutil.iter_modules(plugin.__path__):
print(name, ispkg, f"{plugin.__name__}.{name}")
imported = importlib.import_module(f"{plugin.__name__}.{name}")
if ispkg:
yield from PluginService.modules_for_plugin_in_package(imported, None)
else:
yield name, imported

#
# commands True connector_example.commands
# combine_strings False commands.combine_strings
#

@staticmethod
def modules_for_plugin_in_package(
plugin: types.ModuleType, package_name: str | None
) -> Generator[tuple[str, types.ModuleType], None, None]:
for finder, name, ispkg in pkgutil.iter_modules(plugin.__path__):
print(name, ispkg, f"{plugin.__name__}.{name}")
if ispkg and name == package_name:
found_module = finder.find_module(name) # type: ignore
if found_module is not None:
sub_pkg = found_module.load_module(name)
yield from PluginService.modules_for_plugin_in_package(sub_pkg, None)
elif package_name is None:
imported = importlib.import_module(f"{plugin.__name__}.{name}")
yield from PluginService.modules_for_plugin_in_package(imported, None)
elif not package_name:
spec = finder.find_spec(name) # type: ignore
if spec is not None and spec.loader is not None:
module = types.ModuleType(spec.name)
spec.loader.exec_module(module)
yield name, module
assert False

@staticmethod
def targets_for_plugin(
Expand Down

0 comments on commit 9676e1e

Please sign in to comment.