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