# Path: Peach/transformer.py
# class Transformer(object):
#     """
#     Transformers encode or decode some form of input e.g. Base64 string.
#     Chained transformer run after this transformer.
#     """
# 
#     def __init__(self, anotherTransformer=None):
#         """Create a Transformer object.
# 
#         :param anotherTransformer: a transformer to run next
#         :type anotherTransformer: Transformer
#         """
#         self._anotherTransformer = anotherTransformer
# 
#     def changesSize(self):
#         return True
# 
#     def encode(self, data):
#         """Transform data and call next transformer in chain if provided.
# 
#         :param data: data to transform
#         :type data: str
#         :returns: transformed data
#         :rtype: str
#         """
#         ret = self.realEncode(data)
#         if self._anotherTransformer is not None:
#             return self._anotherTransformer.encode(ret)
#         return ret
# 
#     def decode(self, data):
#         """Perform reverse transformation if possible.
# 
#         :param data: data to transform
#         :type data: str
#         :returns: transformed data
#         :rtype: str
#         """
#         if self._anotherTransformer is not None:
#             data = self._anotherTransformer.decode(data)
#         return self.realDecode(data)
# 
#     def getTransformer(self):
#         """Gets the next transformer in the chain.
# 
#         :returns: next transformer in chain or None
#         :rtype: Transformer
#         """
#         return self._anotherTransformer
# 
#     def addTransformer(self, transformer):
#         """Set the next transformer in the chain.
# 
#         :param transformer: transformer to set
#         :type transformer: Transformer
#         :returns: this transformer
#         :rtype: Transformer
#         """
#         self._anotherTransformer = transformer
#         return self
# 
#     def realEncode(self, data):
#         """Override this method to implement your transform.
# 
#         :param data: data to transform
#         :type data: str
#         :returns: transformed data
#         :rtype: str
#         """
#         raise Exception("realEncode(): Transformer does not work both ways.")
# 
#     def realDecode(self, data):
#         """Override this method to implement your transform.
# 
#         :param data: data to transform
#         :type data: str
#         :returns: transformed data
#         :rtype: str
#         """
#         raise Exception("realDecode(): Transformer does not work both ways.")


import sys
import ctypes as C
import os
from ctypes import util
from Peach.transformer import Transformer
        assert err == Z_OK, err

    def __call__(self, input):
        outbuf = C.create_string_buffer(CHUNK)
        self.st.avail_in = len(input)
        self.st.next_in = C.cast(C.c_char_p(input), C.POINTER(C.c_ubyte))
        self.st.avail_out = CHUNK
        self.st.next_out = C.cast(outbuf, C.POINTER(C.c_ubyte))
        err = _zlib.inflate(C.byref(self.st), Z_SYNC_FLUSH)
        if err == Z_NEED_DICT:
            assert self.dictionary, "no dictionary provided"
            dict_id = _zlib.adler32(0,
                                    C.cast(C.c_char_p(self.dictionary), C.POINTER(C.c_ubyte)),
                                    len(self.dictionary))
            err = _zlib.inflateSetDictionary(
                C.byref(self.st),
                C.cast(C.c_char_p(self.dictionary), C.POINTER(C.c_ubyte)),
                len(self.dictionary)
            )
            assert err == Z_OK, err
            err = _zlib.inflate(C.byref(self.st), Z_SYNC_FLUSH)
        if err in [Z_OK, Z_STREAM_END]:
            return outbuf[:CHUNK - self.st.avail_out]
        else:
            raise AssertionError(err)

    def __del__(self):
        err = _zlib.inflateEnd(C.byref(self.st))



# Path: Peach/transformer.py
# class Transformer(object):
#     """
#     Transformers encode or decode some form of input e.g. Base64 string.
#     Chained transformer run after this transformer.
#     """
# 
#     def __init__(self, anotherTransformer=None):
#         """Create a Transformer object.
# 
#         :param anotherTransformer: a transformer to run next
#         :type anotherTransformer: Transformer
#         """
#         self._anotherTransformer = anotherTransformer
# 
#     def changesSize(self):
#         return True
# 
#     def encode(self, data):
#         """Transform data and call next transformer in chain if provided.
# 
#         :param data: data to transform
#         :type data: str
#         :returns: transformed data
#         :rtype: str
#         """
#         ret = self.realEncode(data)
#         if self._anotherTransformer is not None:
#             return self._anotherTransformer.encode(ret)
#         return ret
# 
#     def decode(self, data):
#         """Perform reverse transformation if possible.
# 
#         :param data: data to transform
#         :type data: str
#         :returns: transformed data
#         :rtype: str
#         """
#         if self._anotherTransformer is not None:
#             data = self._anotherTransformer.decode(data)
#         return self.realDecode(data)
# 
#     def getTransformer(self):
#         """Gets the next transformer in the chain.
# 
#         :returns: next transformer in chain or None
#         :rtype: Transformer
#         """
#         return self._anotherTransformer
# 
#     def addTransformer(self, transformer):
#         """Set the next transformer in the chain.
# 
#         :param transformer: transformer to set
#         :type transformer: Transformer
#         :returns: this transformer
#         :rtype: Transformer
#         """
#         self._anotherTransformer = transformer
#         return self
# 
#     def realEncode(self, data):
#         """Override this method to implement your transform.
# 
#         :param data: data to transform
#         :type data: str
#         :returns: transformed data
#         :rtype: str
#         """
#         raise Exception("realEncode(): Transformer does not work both ways.")
# 
#     def realDecode(self, data):
#         """Override this method to implement your transform.
# 
#         :param data: data to transform
#         :type data: str
#         :returns: transformed data
#         :rtype: str
#         """
#         raise Exception("realDecode(): Transformer does not work both ways.")


# Path: Peach/Transformers/Compression/Zlib.py
import sys
import ctypes as C
import os
from ctypes import util
from Peach.transformer import Transformer

        assert err == Z_OK, err

    def __call__(self, input):
        outbuf = C.create_string_buffer(CHUNK)
        self.st.avail_in = len(input)
        self.st.next_in = C.cast(C.c_char_p(input), C.POINTER(C.c_ubyte))
        self.st.avail_out = CHUNK
        self.st.next_out = C.cast(outbuf, C.POINTER(C.c_ubyte))
        err = _zlib.inflate(C.byref(self.st), Z_SYNC_FLUSH)
        if err == Z_NEED_DICT:
            assert self.dictionary, "no dictionary provided"
            dict_id = _zlib.adler32(0,
                                    C.cast(C.c_char_p(self.dictionary), C.POINTER(C.c_ubyte)),
                                    len(self.dictionary))
            err = _zlib.inflateSetDictionary(
                C.byref(self.st),
                C.cast(C.c_char_p(self.dictionary), C.POINTER(C.c_ubyte)),
                len(self.dictionary)
            )
            assert err == Z_OK, err
            err = _zlib.inflate(C.byref(self.st), Z_SYNC_FLUSH)
        if err in [Z_OK, Z_STREAM_END]:
            return outbuf[:CHUNK - self.st.avail_out]
        else:
            raise AssertionError(err)

    def __del__(self):
        err = _zlib.inflateEnd(C.byref(self.st))



class DictZLib(Transformer):