extension: add entry_point_names method
This allows to get the list of valid entry points names declared for a namespace, without loading them. Change-Id: If9132edc14c2772732fd4ec0dc5dc3ebc4a56b3c
This commit is contained in:
parent
eb04fc4a3e
commit
6d56b58e22
@ -13,6 +13,7 @@
|
|||||||
"""ExtensionManager
|
"""ExtensionManager
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import operator
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
@ -168,6 +169,10 @@ class ExtensionManager(object):
|
|||||||
self.ENTRY_POINT_CACHE[self.namespace] = eps
|
self.ENTRY_POINT_CACHE[self.namespace] = eps
|
||||||
return self.ENTRY_POINT_CACHE[self.namespace]
|
return self.ENTRY_POINT_CACHE[self.namespace]
|
||||||
|
|
||||||
|
def entry_points_names(self):
|
||||||
|
"""Return the list of entry points names for this namespace."""
|
||||||
|
return list(map(operator.attrgetter("name"), self.list_entry_points()))
|
||||||
|
|
||||||
def _load_plugins(self, invoke_on_load, invoke_args, invoke_kwds,
|
def _load_plugins(self, invoke_on_load, invoke_args, invoke_kwds,
|
||||||
verify_requirements):
|
verify_requirements):
|
||||||
extensions = []
|
extensions = []
|
||||||
|
@ -58,6 +58,12 @@ class TestCallback(utils.TestCase):
|
|||||||
set(map(operator.attrgetter("name"), n)))
|
set(map(operator.attrgetter("name"), n)))
|
||||||
self.assertEqual(4, len(n))
|
self.assertEqual(4, len(n))
|
||||||
|
|
||||||
|
def test_list_entry_points_names(self):
|
||||||
|
em = extension.ExtensionManager('stevedore.test.extension')
|
||||||
|
names = em.entry_points_names()
|
||||||
|
self.assertEqual(set(['e1', 'e2', 't1', 't2']), set(names))
|
||||||
|
self.assertEqual(4, len(names))
|
||||||
|
|
||||||
def test_contains_by_name(self):
|
def test_contains_by_name(self):
|
||||||
em = extension.ExtensionManager('stevedore.test.extension')
|
em = extension.ExtensionManager('stevedore.test.extension')
|
||||||
self.assertEqual('t1' in em, True)
|
self.assertEqual('t1' in em, True)
|
||||||
|
Loading…
Reference in New Issue
Block a user