Пример #1
0
def detect_snappy(contents):
    '''
    This is a silly small function which checks to see if the file is Snappy.
    It requires the entire contents of the compressed file.
    This will also return false if snappy decompression if we do not have the library available.
    '''
    try:
        import snappy
        return snappy.isValidCompressed(contents)
    except:
        return False
Пример #2
0
 def test_valid_compressed_buffer(self):
     text = "hello world!".encode('utf-8')
     compressed = snappy.compress(text)
     uncompressed = snappy.uncompress(compressed)
     self.assertEqual(text == uncompressed,
                      snappy.isValidCompressed(compressed))
Пример #3
0
 def is_snappy(value):
     return snappy.isValidCompressed(value)
Пример #4
0
 def test_invalid_compressed_buffer(self):
     self.assertFalse(snappy.isValidCompressed(
             "not compressed".encode('utf-8')))
Пример #5
0
 def test_invalid_compressed_buffer(self):
     self.assertFalse(snappy.isValidCompressed("not compressed"))