Coverage for slidge/__init__.py: 88%

25 statements  

« prev     ^ index     » next       coverage.py v7.11.3, created at 2025-11-26 19:34 +0000

1""" 

2The main slidge package. 

3 

4Contains importable classes for a minimal function :term:`Legacy Module`. 

5""" 

6 

7import warnings 

8from importlib.metadata import PackageNotFoundError, version 

9from typing import Any 

10 

11from . import slixfix # noqa: F401 

12from .command import FormField, SearchResult # noqa: F401 

13from .contact import LegacyContact, LegacyRoster # noqa: F401 

14from .core import config as global_config # noqa: F401 

15from .core.gateway import BaseGateway # noqa: F401 

16from .core.session import BaseSession # noqa: F401 

17from .db import GatewayUser # noqa: F401 

18from .group import LegacyBookmarks, LegacyMUC, LegacyParticipant # noqa: F401 

19from .main import main as main_func 

20from .util.types import MucType # noqa: F401 

21from .util.util import addLoggingLevel 

22 

23 

24def entrypoint(module_name: str) -> None: 

25 """ 

26 Entrypoint to be used in ``__main__.py`` of 

27 :term:`legacy modules <Legacy Module>`. 

28 

29 :param module_name: An importable :term:`Legacy Module`. 

30 """ 

31 main_func(module_name) 

32 

33 

34def formatwarning( 

35 message: Any, category: Any, filename: Any, lineno: Any, line: str = "" 

36) -> str: 

37 return f"{filename}:{lineno}:{category.__name__}:{message}\n" 

38 

39 

40warnings.formatwarning = formatwarning # type:ignore 

41 

42try: 

43 __version__ = version("slidge") 

44except PackageNotFoundError: 

45 # package is not installed 

46 __version__ = "dev" 

47 

48 

49__all__ = [ 

50 "__version__", 

51 "BaseGateway", 

52 "BaseSession", 

53 # For backwards compatibility, these names are still importable from the 

54 # top-level slidge module, but this is deprecated. 

55 # "GatewayUser", 

56 # "LegacyBookmarks", 

57 # "LegacyMUC", 

58 # "LegacyContact", 

59 # "LegacyParticipant", 

60 # "LegacyRoster", 

61 # "MucType", 

62 # "FormField", 

63 # "SearchResult", 

64 "entrypoint", 

65 "global_config", 

66] 

67 

68addLoggingLevel()