Coverage for slidge/__init__.py: 86%

21 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-11-07 05:11 +0000

1""" 

2The main slidge package. 

3 

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

5""" 

6 

7import sys 

8import warnings 

9 

10from . import slixfix # noqa: F401 

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

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

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

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

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

16from .db import GatewayUser # noqa: F401 

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

18from .main import main as main_func 

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

20from .util.util import addLoggingLevel 

21 

22 

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

24 """ 

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

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

27 

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

29 """ 

30 sys.argv.extend(["--legacy", module_name]) 

31 main_func() 

32 

33 

34def formatwarning(message, category, filename, lineno, line=""): 

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

36 

37 

38warnings.formatwarning = formatwarning 

39 

40 

41__all__ = [ 

42 "BaseGateway", 

43 "BaseSession", 

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

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

46 # "GatewayUser", 

47 # "LegacyBookmarks", 

48 # "LegacyMUC", 

49 # "LegacyContact", 

50 # "LegacyParticipant", 

51 # "LegacyRoster", 

52 # "MucType", 

53 # "FormField", 

54 # "SearchResult", 

55 "entrypoint", 

56 "global_config", 

57] 

58 

59addLoggingLevel()