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.

40 lines
1.3 KiB

7 years ago
  1. # Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
  2. #
  3. # This file is part of paramiko.
  4. #
  5. # Paramiko is free software; you can redistribute it and/or modify it under the
  6. # terms of the GNU Lesser General Public License as published by the Free
  7. # Software Foundation; either version 2.1 of the License, or (at your option)
  8. # any later version.
  9. #
  10. # Paramiko is distributed in the hope that it will be useful, but WITHOUT ANY
  11. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. # A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  13. # details.
  14. #
  15. # You should have received a copy of the GNU Lesser General Public License
  16. # along with Paramiko; if not, write to the Free Software Foundation, Inc.,
  17. # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  18. """
  19. Compression implementations for a Transport.
  20. """
  21. import zlib
  22. class ZlibCompressor (object):
  23. def __init__(self):
  24. # Use the default level of zlib compression
  25. self.z = zlib.compressobj()
  26. def __call__(self, data):
  27. return self.z.compress(data) + self.z.flush(zlib.Z_FULL_FLUSH)
  28. class ZlibDecompressor (object):
  29. def __init__(self):
  30. self.z = zlib.decompressobj()
  31. def __call__(self, data):
  32. return self.z.decompress(data)

Powered by TurnKey Linux.