Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
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.

compress.py 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. ###############################################################################
  2. #
  3. # The MIT License (MIT)
  4. #
  5. # Copyright (c) typedef int GmbH
  6. #
  7. # Permission is hereby granted, free of charge, to any person obtaining a copy
  8. # of this software and associated documentation files (the "Software"), to deal
  9. # in the Software without restriction, including without limitation the rights
  10. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. # copies of the Software, and to permit persons to whom the Software is
  12. # furnished to do so, subject to the following conditions:
  13. #
  14. # The above copyright notice and this permission notice shall be included in
  15. # all copies or substantial portions of the Software.
  16. #
  17. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. # THE SOFTWARE.
  24. #
  25. ###############################################################################
  26. from autobahn.websocket.compress_base import \
  27. PerMessageCompressOffer, \
  28. PerMessageCompressOfferAccept, \
  29. PerMessageCompressResponse, \
  30. PerMessageCompressResponseAccept, \
  31. PerMessageCompress
  32. from autobahn.websocket.compress_deflate import \
  33. PerMessageDeflateMixin, \
  34. PerMessageDeflateOffer, \
  35. PerMessageDeflateOfferAccept, \
  36. PerMessageDeflateResponse, \
  37. PerMessageDeflateResponseAccept, \
  38. PerMessageDeflate
  39. # this must be a list (not tuple), since we dynamically
  40. # extend it ..
  41. __all__ = [
  42. 'PerMessageCompressOffer',
  43. 'PerMessageCompressOfferAccept',
  44. 'PerMessageCompressResponse',
  45. 'PerMessageCompressResponseAccept',
  46. 'PerMessageCompress',
  47. 'PerMessageDeflateOffer',
  48. 'PerMessageDeflateOfferAccept',
  49. 'PerMessageDeflateResponse',
  50. 'PerMessageDeflateResponseAccept',
  51. 'PerMessageDeflate',
  52. 'PERMESSAGE_COMPRESSION_EXTENSION'
  53. ]
  54. # map of available compression extensions
  55. PERMESSAGE_COMPRESSION_EXTENSION = {
  56. # class for 'permessage-deflate' is always available
  57. PerMessageDeflateMixin.EXTENSION_NAME: {
  58. 'Offer': PerMessageDeflateOffer,
  59. 'OfferAccept': PerMessageDeflateOfferAccept,
  60. 'Response': PerMessageDeflateResponse,
  61. 'ResponseAccept': PerMessageDeflateResponseAccept,
  62. 'PMCE': PerMessageDeflate
  63. }
  64. }
  65. # include 'permessage-bzip2' classes if bzip2 is available
  66. try:
  67. import bz2
  68. except ImportError:
  69. bz2 = None
  70. else:
  71. from autobahn.websocket.compress_bzip2 import \
  72. PerMessageBzip2Mixin, \
  73. PerMessageBzip2Offer, \
  74. PerMessageBzip2OfferAccept, \
  75. PerMessageBzip2Response, \
  76. PerMessageBzip2ResponseAccept, \
  77. PerMessageBzip2
  78. PMCE = {
  79. 'Offer': PerMessageBzip2Offer,
  80. 'OfferAccept': PerMessageBzip2OfferAccept,
  81. 'Response': PerMessageBzip2Response,
  82. 'ResponseAccept': PerMessageBzip2ResponseAccept,
  83. 'PMCE': PerMessageBzip2
  84. }
  85. PERMESSAGE_COMPRESSION_EXTENSION[PerMessageBzip2Mixin.EXTENSION_NAME] = PMCE
  86. __all__.extend(['PerMessageBzip2Offer',
  87. 'PerMessageBzip2OfferAccept',
  88. 'PerMessageBzip2Response',
  89. 'PerMessageBzip2ResponseAccept',
  90. 'PerMessageBzip2'])
  91. # include 'permessage-snappy' classes if Snappy is available
  92. try:
  93. # noinspection PyPackageRequirements
  94. import snappy
  95. except ImportError:
  96. snappy = None
  97. else:
  98. from autobahn.websocket.compress_snappy import \
  99. PerMessageSnappyMixin, \
  100. PerMessageSnappyOffer, \
  101. PerMessageSnappyOfferAccept, \
  102. PerMessageSnappyResponse, \
  103. PerMessageSnappyResponseAccept, \
  104. PerMessageSnappy
  105. PMCE = {
  106. 'Offer': PerMessageSnappyOffer,
  107. 'OfferAccept': PerMessageSnappyOfferAccept,
  108. 'Response': PerMessageSnappyResponse,
  109. 'ResponseAccept': PerMessageSnappyResponseAccept,
  110. 'PMCE': PerMessageSnappy
  111. }
  112. PERMESSAGE_COMPRESSION_EXTENSION[PerMessageSnappyMixin.EXTENSION_NAME] = PMCE
  113. __all__.extend(['PerMessageSnappyOffer',
  114. 'PerMessageSnappyOfferAccept',
  115. 'PerMessageSnappyResponse',
  116. 'PerMessageSnappyResponseAccept',
  117. 'PerMessageSnappy'])