Debian Codegraph @

envisage/service_offer.py

raw
1 # (C) Copyright 2007-2025 Enthought, Inc., Austin, TX
2 # All rights reserved.
3 #
4 # This software is provided without warranty under the terms of the BSD
5 # license included in LICENSE.txt and may be redistributed only under
6 # the conditions described in the aforementioned license. The license
7 # is also available online at http://www.enthought.com/licenses/BSD.txt
8 #
9 # Thanks for using Enthought open source!
10 """ An offer to provide a service. """
11
12
13 # Enthought library imports.
14 from traits.api import Callable, Dict, HasTraits, Str, Type, Union
15
16
17 class ServiceOffer(HasTraits):
18 """An offer to provide a service."""
19
20 #### 'ServiceOffer' interface #############################################
21
22 #: The protocol that the service provides.
23 #:
24 #: This can be an actual class or interface, or a string that can be used
25 #: to import a class or interface.
26 #:
27 #: e.g. 'foo.bar.baz.Baz' is turned into 'from foo.bar.baz import Baz'
28 protocol = Union(Str, Type)
29
30 #: A callable (or a string that can be used to import a callable) that is
31 #: the factory that creates the actual service object.
32 #:
33 #: e.g::
34 #:
35 #: callable(**properties) -> Any
36 #:
37 #: e.g. 'foo.bar.baz.Baz' is turned into 'from foo.bar.baz import Baz'
38 factory = Union(Str, Callable)
39
40 #: An optional set of properties to associate with the service offer.
41 #:
42 #: This dictionary is passed as keyword arguments to the factory.
43 properties = Dict