Migrate to importlib.metadata
pkg_resources is removed in Python 3.12. Change-Id: I6ea6d9eb098378dbab52cceb9aa6df335ef9407b Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
b155daa427
commit
1b42c9de74
|
@ -2,3 +2,4 @@ WebOb>=1.8.0
|
||||||
simplegeneric
|
simplegeneric
|
||||||
pytz
|
pytz
|
||||||
netaddr>=0.7.12
|
netaddr>=0.7.12
|
||||||
|
importlib_metadata>=1.7.0;python_version<'3.8' # Apache-2.0
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
import pkg_resources
|
try:
|
||||||
|
import importlib.metadata as importlib_metadata
|
||||||
|
except ImportError: # Python < 3.8
|
||||||
|
import importlib_metadata
|
||||||
|
|
||||||
from wsme.exc import ClientSideError
|
from wsme.exc import ClientSideError
|
||||||
|
|
||||||
|
@ -106,8 +109,7 @@ def register_protocol(protocol):
|
||||||
def getprotocol(name, **options):
|
def getprotocol(name, **options):
|
||||||
protocol_class = registered_protocols.get(name)
|
protocol_class = registered_protocols.get(name)
|
||||||
if protocol_class is None:
|
if protocol_class is None:
|
||||||
for entry_point in pkg_resources.iter_entry_points(
|
for entry_point in importlib_metadata.entry_points()['wsme.protocols']:
|
||||||
'wsme.protocols', name):
|
|
||||||
if entry_point.name == name:
|
if entry_point.name == name:
|
||||||
protocol_class = entry_point.load()
|
protocol_class = entry_point.load()
|
||||||
if protocol_class is None:
|
if protocol_class is None:
|
||||||
|
|
Loading…
Reference in New Issue