File manager - Edit - /opt/imh-python/lib/python2.7/site-packages/stevedore/dispatch.pyc
Back
� ��Wc @ sk d d l Z d d l m Z d d l m Z e j e � Z d e f d � � YZ d e f d � � YZ d S( i����Ni ( t EnabledExtensionManager( t NoMatchest DispatchExtensionManagerc B s e Z d Z d � Z d � Z RS( sF Loads all plugins and filters on execution. This is useful for long-running processes that need to pass different inputs to different extensions. :param namespace: The namespace for the entry points. :type namespace: str :param check_func: Function to determine which extensions to load. :type check_func: callable :param invoke_on_load: Boolean controlling whether to invoke the object returned by the entry point after the driver is loaded. :type invoke_on_load: bool :param invoke_args: Positional arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True. :type invoke_args: tuple :param invoke_kwds: Named arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True. :type invoke_kwds: dict :param propagate_map_exceptions: Boolean controlling whether exceptions are propagated up through the map call or whether they are logged and then ignored :type invoke_on_load: bool c O sn | j s t d | j � � n g } xB | j D]7 } | | | | � r/ | j | j | | | | � q/ q/ W| S( s| Iterate over the extensions invoking func() for any where filter_func() returns True. The signature of filter_func() should be:: def filter_func(ext, *args, **kwds): pass The first argument to filter_func(), 'ext', is the :class:`~stevedore.extension.Extension` instance. filter_func() should return True if the extension should be invoked for the input arguments. The signature for func() should be:: def func(ext, *args, **kwds): pass The first argument to func(), 'ext', is the :class:`~stevedore.extension.Extension` instance. Exceptions raised from within func() are propagated up and processing stopped if self.propagate_map_exceptions is True, otherwise they are logged and ignored. :param filter_func: Callable to test each extension. :param func: Callable to invoke for each extension. :param args: Variable arguments to pass to func() :param kwds: Keyword arguments to pass to func() :returns: List of values returned from func() s No %s extensions found( t extensionsR t namespacet _invoke_one_plugint append( t selft filter_funct funct argst kwdst responset e( ( s5 /tmp/pip-build-T5Mfvc/stevedore/stevedore/dispatch.pyt map$ s #c O s | j | | j | | | � S( sU Iterate over the extensions invoking each one's object method called `method_name` for any where filter_func() returns True. This is equivalent of using :meth:`map` with func set to `lambda x: x.obj.method_name()` while being more convenient. Exceptions raised from within the called method are propagated up and processing stopped if self.propagate_map_exceptions is True, otherwise they are logged and ignored. .. versionadded:: 0.12 :param filter_func: Callable to test each extension. :param method_name: The extension method name to call for each extension. :param args: Variable arguments to pass to method :param kwds: Keyword arguments to pass to method :returns: List of values returned from methods ( R t _call_extension_method( R R t method_nameR R ( ( s5 /tmp/pip-build-T5Mfvc/stevedore/stevedore/dispatch.pyt map_methodM s ( t __name__t __module__t __doc__R R ( ( ( s5 /tmp/pip-build-T5Mfvc/stevedore/stevedore/dispatch.pyR s )t NameDispatchExtensionManagerc B sD e Z d Z e d i e d e d � Z d � Z d � Z d � Z RS( s5 Loads all plugins and filters on execution. This is useful for long-running processes that need to pass different inputs to different extensions and can predict the name of the extensions before calling them. The check_func argument should return a boolean, with ``True`` indicating that the extension should be loaded and made available and ``False`` indicating that the extension should be ignored. :param namespace: The namespace for the entry points. :type namespace: str :param check_func: Function to determine which extensions to load. :type check_func: callable :param invoke_on_load: Boolean controlling whether to invoke the object returned by the entry point after the driver is loaded. :type invoke_on_load: bool :param invoke_args: Positional arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True. :type invoke_args: tuple :param invoke_kwds: Named arguments to pass when invoking the object returned by the entry point. Only used if invoke_on_load is True. :type invoke_kwds: dict :param propagate_map_exceptions: Boolean controlling whether exceptions are propagated up through the map call or whether they are logged and then ignored :type invoke_on_load: bool :param on_load_failure_callback: Callback function that will be called when a entrypoint can not be loaded. The arguments that will be provided when this is called (when an entrypoint fails to load) are (manager, entrypoint, exception) :type on_load_failure_callback: function :param verify_requirements: Use setuptools to enforce the dependencies of the plugin(s) being loaded. Defaults to False. :type verify_requirements: bool c C sG t t | � j d | d | d | d | d | d | d | d | � d S( NR t check_funct invoke_on_loadt invoke_argst invoke_kwdst propagate_map_exceptionst on_load_failure_callbackt verify_requirements( t superR t __init__( R R R R R R R R R ( ( s5 /tmp/pip-build-T5Mfvc/stevedore/stevedore/dispatch.pyR � s c C s6 t t | � j | � t d � | j D� � | _ d S( Nc s s | ] } | j | f Vq d S( N( t name( t .0R ( ( s5 /tmp/pip-build-T5Mfvc/stevedore/stevedore/dispatch.pys <genexpr>� s ( R R t _init_pluginst dictR t by_name( R R ( ( s5 /tmp/pip-build-T5Mfvc/stevedore/stevedore/dispatch.pyR! � s c O sl g } x_ | D]W } y | j | } Wn! t k rG t j d | � q X| j | j | | | | � q W| S( s5 Iterate over the extensions invoking func() for any where the name is in the given list of names. The signature for func() should be:: def func(ext, *args, **kwds): pass The first argument to func(), 'ext', is the :class:`~stevedore.extension.Extension` instance. Exceptions raised from within func() are propagated up and processing stopped if self.propagate_map_exceptions is True, otherwise they are logged and ignored. :param names: List or set of name(s) of extension(s) to invoke. :param func: Callable to invoke for each extension. :param args: Variable arguments to pass to func() :param kwds: Keyword arguments to pass to func() :returns: List of values returned from func() s"