Coverage for slidge / __init__.py: 83%
24 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-03-13 22:59 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2026-03-13 22:59 +0000
1"""
2The main slidge package.
4Contains importable classes for a minimal function :term:`Legacy Module`.
5"""
7import warnings
8from importlib.metadata import PackageNotFoundError, version
10from . import (
11 slixfix, # noqa: F401
12 util,
13)
14from .command import FormField, SearchResult # noqa: F401
15from .contact import LegacyContact, LegacyRoster # noqa: F401
16from .core import config as global_config # noqa: F401
17from .core.gateway import BaseGateway # noqa: F401
18from .core.session import BaseSession # noqa: F401
19from .db import GatewayUser # noqa: F401
20from .group import LegacyBookmarks, LegacyMUC, LegacyParticipant # noqa: F401
21from .main import main as main_func
22from .util.types import MucType # noqa: F401
23from .util.util import addLoggingLevel
26def entrypoint(module_name: str) -> None:
27 """
28 Entrypoint to be used in ``__main__.py`` of
29 :term:`legacy modules <Legacy Module>`.
31 :param module_name: An importable :term:`Legacy Module`.
32 """
33 main_func(module_name)
36def formatwarning(
37 message: Warning | str,
38 category: type[Warning],
39 filename: str,
40 lineno: int,
41 line: str = "",
42) -> str:
43 return f"{filename}:{lineno}:{category.__name__}:{message}\n"
46warnings.formatwarning = formatwarning # type:ignore
48try:
49 __version__ = version("slidge")
50except PackageNotFoundError:
51 # package is not installed
52 __version__ = "dev"
55__all__ = [
56 "__version__",
57 "BaseGateway",
58 "BaseSession",
59 # For backwards compatibility, these names are still importable from the
60 # top-level slidge module, but this is deprecated.
61 # "GatewayUser",
62 # "LegacyBookmarks",
63 # "LegacyMUC",
64 # "LegacyContact",
65 # "LegacyParticipant",
66 # "LegacyRoster",
67 # "MucType",
68 # "FormField",
69 # "SearchResult",
70 "entrypoint",
71 "global_config",
72 "util",
73]
75addLoggingLevel()