Beispiel #1
0
 def test_compress_decompress(self):
     bytes = range(128) * 10000
     string = str(bytearray(bytes))
     encoded = pngcompression.encode(string)
     self.assertNotEqual(string, encoded)
     decoded = pngcompression.decode(encoded)
     self.assertEqual(string, decoded)
 def test_compress_decompress(self):
     bytes = list(range(128)) * 10000
     string = str(bytearray(bytes))
     encoded = pngcompression.encode(string)
     self.assertNotEqual(string, encoded)
     decoded = pngcompression.decode(encoded)
     self.assertEqual(string, decoded)
    def test_decode_png(self):
        with open('pngmsg.txt', 'r') as outfile:
            data = outfile.read()

        #dict_png=json.loads(sample_png)
        #data= dict_png["data"]

        #data="Salam1234!--- 'ASS':'12243.384764'"
        #data = pngcompression.encode(data)

        decoded = pngcompression.decode(data)

        with open('decodedagain_png.txt', 'w') as outfile:
            outfile.write(decoded)

        print("done")
 def decompress(self, topic, data):
     if self.incoming_topics_compression_state.get(topic) == "png":
         data = pngcompression.decode(data)
         return json.loads(data)
     else:
         return data