Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

__init__.py 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. """Messaging library for Python"""
  2. from __future__ import absolute_import
  3. import os
  4. import sys
  5. from collections import namedtuple
  6. from types import ModuleType
  7. version_info_t = namedtuple(
  8. 'version_info_t', ('major', 'minor', 'micro', 'releaselevel', 'serial'),
  9. )
  10. VERSION = version_info_t(3, 0, 37, '', '')
  11. __version__ = '{0.major}.{0.minor}.{0.micro}{0.releaselevel}'.format(VERSION)
  12. __author__ = 'Ask Solem'
  13. __contact__ = 'ask@celeryproject.org'
  14. __homepage__ = 'https://kombu.readthedocs.io'
  15. __docformat__ = 'restructuredtext en'
  16. # -eof meta-
  17. if sys.version_info < (2, 6): # pragma: no cover
  18. raise Exception('Kombu 3.1 requires Python versions 2.6 or later.')
  19. STATICA_HACK = True
  20. globals()['kcah_acitats'[::-1].upper()] = False
  21. if STATICA_HACK: # pragma: no cover
  22. # This is never executed, but tricks static analyzers (PyDev, PyCharm,
  23. # pylint, etc.) into knowing the types of these symbols, and what
  24. # they contain.
  25. from kombu.connection import Connection, BrokerConnection # noqa
  26. from kombu.entity import Exchange, Queue, binding # noqa
  27. from kombu.messaging import Consumer, Producer # noqa
  28. from kombu.pools import connections, producers # noqa
  29. from kombu.utils.url import parse_url # noqa
  30. from kombu.common import eventloop, uuid # noqa
  31. from kombu.serialization import ( # noqa
  32. enable_insecure_serializers,
  33. disable_insecure_serializers,
  34. )
  35. # Lazy loading.
  36. # - See werkzeug/__init__.py for the rationale behind this.
  37. all_by_module = {
  38. 'kombu.connection': ['Connection', 'BrokerConnection'],
  39. 'kombu.entity': ['Exchange', 'Queue', 'binding'],
  40. 'kombu.messaging': ['Consumer', 'Producer'],
  41. 'kombu.pools': ['connections', 'producers'],
  42. 'kombu.utils.url': ['parse_url'],
  43. 'kombu.common': ['eventloop', 'uuid'],
  44. 'kombu.serialization': ['enable_insecure_serializers',
  45. 'disable_insecure_serializers'],
  46. }
  47. object_origins = {}
  48. for module, items in all_by_module.items():
  49. for item in items:
  50. object_origins[item] = module
  51. class module(ModuleType):
  52. def __getattr__(self, name):
  53. if name in object_origins:
  54. module = __import__(object_origins[name], None, None, [name])
  55. for extra_name in all_by_module[module.__name__]:
  56. setattr(self, extra_name, getattr(module, extra_name))
  57. return getattr(module, name)
  58. return ModuleType.__getattribute__(self, name)
  59. def __dir__(self):
  60. result = list(new_module.__all__)
  61. result.extend(('__file__', '__path__', '__doc__', '__all__',
  62. '__docformat__', '__name__', '__path__', 'VERSION',
  63. '__package__', '__version__', '__author__',
  64. '__contact__', '__homepage__', '__docformat__'))
  65. return result
  66. # 2.5 does not define __package__
  67. try:
  68. package = __package__
  69. except NameError: # pragma: no cover
  70. package = 'kombu'
  71. # keep a reference to this module so that it's not garbage collected
  72. old_module = sys.modules[__name__]
  73. new_module = sys.modules[__name__] = module(__name__)
  74. new_module.__dict__.update({
  75. '__file__': __file__,
  76. '__path__': __path__,
  77. '__doc__': __doc__,
  78. '__all__': tuple(object_origins),
  79. '__version__': __version__,
  80. '__author__': __author__,
  81. '__contact__': __contact__,
  82. '__homepage__': __homepage__,
  83. '__docformat__': __docformat__,
  84. '__package__': package,
  85. 'version_info_t': version_info_t,
  86. 'VERSION': VERSION})
  87. if os.environ.get('KOMBU_LOG_DEBUG'): # pragma: no cover
  88. os.environ.update(KOMBU_LOG_CHANNEL='1', KOMBU_LOG_CONNECTION='1')
  89. from .utils import debug
  90. debug.setup_logging()