Esempio n. 1
0
    def decompress(self, data, file_name, k):
        decompressor = Decompressor(data=data,
                                    dictionary=self.init_decode_dictionary(
                                        k=k,
                                        file_type=file_name.split(".")[-1]))
        decoded_message = decompressor.run()

        return decoded_message
Esempio n. 2
0
    def test_digestHeader2(self):
        header = '010110010110111000000000'
        expected = {
            112: '1',
            101: '0',
        }

        expected = Decompressor(None, None).flipMap(expected)
        self.assertEquals(len(header) % 8, 0)
        f = self.getIOBuff(header)

        actual = Decompressor(None, None).digestHeader(f)
        self.assertEqual(expected, actual)
Esempio n. 3
0
def extract_and_hash(f, url, parent, store_plaintext):
    d = Decompressor(f)
    fmt = d.get_fmt()
    if fmt is not None:
        with TempDirectory() as tmp_dir:
            extracted = d.extract(fmt, tmp_dir)
            for filename in extracted:
                yield hashdd_helper(
                    filename, store_plaintext, {
                        Features.FILE_NAME.value: [basename(filename)],
                        Features.PARENTS.value: [parent],
                        Features.FILE_ABSOLUTE_PATH.value:
                        [dirname(filename[len(tmp_dir) + 1:])],
                        Features.SOURCE_URLS.value: [url]
                    })
Esempio n. 4
0
 def test_getMyByte2(self):
     bytes = 107
     nextBytes = 46
     bitNum = 3
     expected = 101
     actual = Decompressor(None, None).getMyByte(bytes, nextBytes, bitNum)
     self.assertEqual(expected, actual)
Esempio n. 5
0
    def test_getMyByte(self):

        bytes = 2
        nextBytes = 26
        bitNum = 4
        expected = 33
        actual = Decompressor(None, None).getMyByte(bytes, nextBytes, bitNum)
        self.assertEqual(expected, actual)
Esempio n. 6
0
    def test_decompressFile1(self):
        reverseMap = {
            '101': ord('b'),
            '100': ord('o'),
            '11': ord('x'),
            '00': ord('z'),
            '01': 3,
        }
        newBytes = [178, 92, 2]  # boobxzF
        expected = [98, 111, 111, 98, 120, 122]

        actual = Decompressor(None, None).decompressFile(newBytes, reverseMap)
        self.assertEqual(expected, actual)
Esempio n. 7
0
from compressor import Compressor
from decompressor import Decompressor

inputFileName = 'debug.txt'
compressedFileName = 'compress.zip'
decompressedFileName = 'uncompress.txt'

Compressor(inputFileName, compressedFileName).run()
Decompressor(compressedFileName, decompressedFileName).run()