summaryrefslogtreecommitdiff
path: root/stevedore/named.py
blob: cfa5a2dd36bd7815739247829f3337661d7f0c03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from .enabled import EnabledExtensionManager


class NamedExtensionManager(EnabledExtensionManager):
    """ExtensionManager that only loads the named extensions.

    This is useful for explictly enabling extensions in a
    configuration file, for example.
    """

    def __init__(self, namespace, names=[],
                 invoke_on_load=False, invoke_args=(), invoke_kwds={}):
        def check(ep):
            return ep.name in names
        super(NamedExtensionManager, self).__init__(namespace,
                                                    check,
                                                    invoke_on_load=invoke_on_load,
                                                    invoke_args=invoke_args,
                                                    invoke_kwds=invoke_kwds,
                                                    )