File tree Expand file tree Collapse file tree 4 files changed +12
-8
lines changed
Expand file tree Collapse file tree 4 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 1+ Replace usage of pkg_resources.iter_entry_points, update exception message
Original file line number Diff line number Diff line change 44import logging
55from collections import defaultdict
66from typing import Optional
7- from pkg_resources import iter_entry_points
7+ from importlib . metadata import entry_points
88
99import click
1010import sys
@@ -187,7 +187,7 @@ def _get_commands_from_entry_point(entry_point: str = 'ckan.click_command'):
187187
188188 """
189189 registered_entries = {}
190- for entry in iter_entry_points ( entry_point ): # type: ignore
190+ for entry in entry_points ( group = entry_point ):
191191 if entry .name in registered_entries :
192192 error_shout ((
193193 u'Attempt to override entry_point `{name}`.\n '
Original file line number Diff line number Diff line change @@ -36,7 +36,10 @@ def __init__(self, name: str):
3636 self .name = name
3737
3838 def __str__ (self ):
39- return f"Interface { self .name } does not exist"
39+ return (
40+ f"Plugin '{ self .name } ' not found.\n \n "
41+ "Did you install the 'ckanext-*' Python package that contains the plugin?"
42+ )
4043
4144
4245class Interface :
Original file line number Diff line number Diff line change 77from contextlib import contextmanager
88from typing import Generic , Iterator , TypeVar
99from typing_extensions import TypeGuard
10- from pkg_resources import iter_entry_points
10+ from importlib . metadata import entry_points
1111
1212
1313from ckan .common import config , aslist
@@ -240,10 +240,10 @@ def _get_service(plugin_name: str) -> Plugin:
240240 >>> assert isinstance(plugin, ActivityPlugin)
241241 """
242242 for group in GROUPS :
243- iterator = iter_entry_points (group = group ,name = plugin_name ) # type: ignore
244- plugin = next ( iterator , None )
245- if plugin :
246- return plugin . load ()( name = plugin_name )
243+ ep = entry_points (group = group , name = plugin_name )
244+ if ep :
245+ return ep [ plugin_name ]. load ()( name = plugin_name )
246+
247247 raise PluginNotFoundException (plugin_name )
248248
249249
You can’t perform that action at this time.
0 commit comments