@@ -76,48 +76,21 @@ def command_named(plugin_display_name: str, command_name: str) -> type[Connector
76
76
return available_commands_by_plugin [plugin_name ][command_name ]
77
77
except Exception :
78
78
return None
79
-
80
- #
81
- # commands True connector_example.commands
82
- # combine_strings False connector_example.commands.combine_strings
83
- # some_helper False connector_example.some_helper
84
- #
85
79
86
- @staticmethod
87
- def modules_for_plugin_in_package2 (
88
- plugin : types .ModuleType , package_name : str | None
89
- ) -> Generator [tuple [str , types .ModuleType ], None , None ]:
90
- for finder , name , ispkg in pkgutil .iter_modules (plugin .__path__ ):
91
- print (name , ispkg , f"{ plugin .__name__ } .{ name } " )
92
- imported = importlib .import_module (f"{ plugin .__name__ } .{ name } " )
93
- if ispkg :
94
- yield from PluginService .modules_for_plugin_in_package (imported , None )
95
- else :
96
- yield name , imported
97
-
98
- #
99
- # commands True connector_example.commands
100
- # combine_strings False commands.combine_strings
101
- #
102
-
103
80
@staticmethod
104
81
def modules_for_plugin_in_package (
105
82
plugin : types .ModuleType , package_name : str | None
106
83
) -> Generator [tuple [str , types .ModuleType ], None , None ]:
107
84
for finder , name , ispkg in pkgutil .iter_modules (plugin .__path__ ):
108
- print (name , ispkg , f"{ plugin .__name__ } .{ name } " )
109
85
if ispkg and name == package_name :
110
- found_module = finder .find_module (name ) # type: ignore
111
- if found_module is not None :
112
- sub_pkg = found_module .load_module (name )
113
- yield from PluginService .modules_for_plugin_in_package (sub_pkg , None )
114
- elif package_name is None :
86
+ imported = importlib .import_module (f"{ plugin .__name__ } .{ name } " )
87
+ yield from PluginService .modules_for_plugin_in_package (imported , None )
88
+ elif not package_name :
115
89
spec = finder .find_spec (name ) # type: ignore
116
90
if spec is not None and spec .loader is not None :
117
91
module = types .ModuleType (spec .name )
118
92
spec .loader .exec_module (module )
119
93
yield name , module
120
- assert False
121
94
122
95
@staticmethod
123
96
def targets_for_plugin (
0 commit comments