コード例 #1
0
ファイル: views.py プロジェクト: ixiaoshayu/hue
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
ファイル: test_snappy.py プロジェクト: zebman95/python-snappy
 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
ファイル: test_snappy.py プロジェクト: zebman95/python-snappy
 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"))