File: __init__.py

package info (click to toggle)
python-varlink 31.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 372 kB
  • sloc: python: 2,462; sh: 177; makefile: 31
file content (60 lines) | stat: -rw-r--r-- 2,556 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""An implementation of the varlink protocol

See https://www.varlink.org for more information about the varlink protocol and interface definition
files.

For server implementations use the :class:`varlink.Server` class.

For client implementations use the :class:`varlink.Client` class.

For installation and examples, see the GIT repository https://github.com/varlink/python.
or the `source code <_modules/varlink/tests/test_orgexamplemore.html>`_ of
:mod:`varlink.tests.test_orgexamplemore`

"""

import os

if hasattr(os, "fork"):
    __all__ = ['Client', 'ClientInterfaceHandler', 'SimpleClientInterfaceHandler',
               'Service', 'RequestHandler', 'Server', 'ThreadingServer', 'ForkingServer',
               'InterfaceNotFound', 'MethodNotFound', 'MethodNotImplemented', 'InvalidParameter',
               'ConnectionError', 'VarlinkEncoder', 'VarlinkError',
               'Interface', 'Scanner', 'get_listen_fd']
    from .server import ForkingServer
else:
    __all__ = ['Client', 'ClientInterfaceHandler', 'SimpleClientInterfaceHandler',
               'Service', 'RequestHandler', 'Server', 'ThreadingServer',
               'InterfaceNotFound', 'MethodNotFound', 'MethodNotImplemented', 'InvalidParameter',
               'ConnectionError', 'VarlinkEncoder', 'VarlinkError',
               'Interface', 'Scanner', 'get_listen_fd']

from .client import (Client, ClientInterfaceHandler, SimpleClientInterfaceHandler)
from .error import (VarlinkEncoder, VarlinkError, InvalidParameter, InterfaceNotFound, MethodNotImplemented,
                    MethodNotFound, ConnectionError, BrokenPipeError)
from .scanner import (Scanner, Interface)
from .server import (Service, get_listen_fd, Server, ThreadingServer, RequestHandler)


# There are no tests here, so don't try to run anything discovered from
# introspecting the symbols (e.g. FunctionTestCase). Instead, all our
# tests come from within varlink.tests.
def load_tests(loader, tests, pattern):
    import os.path
    import sys
    from fnmatch import fnmatch

    if pattern == None:
        pattern = "test_*.py"

    # top level directory cached on loader instance
    test_dir = os.path.dirname(__file__) + "/tests"
    for fn in os.listdir(test_dir):
        if fnmatch(fn, pattern):
            if sys.version_info[0] == 2 and fn == "test_mocks.py":
                continue
            modname = "varlink.tests." + fn[:-3]
            __import__(modname)
            module = sys.modules[modname]
            tests.addTest(loader.loadTestsFromModule(module))
    return tests