How to use the extractcode.archive.uncompress_gzip function in extractcode

To help you get started, we’ve selected a few extractcode examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nexB / scancode-toolkit / tests / extractcode / test_extract.py View on Github external
def test_uncompress_corrupted_archive_with_zlib(self):
        from extractcode import archive
        import zlib
        test_dir = self.get_test_loc('extract/corrupted/a.tar.gz', copy=True)
        target_dir = self.get_temp_dir()
        try:
            list(archive.uncompress_gzip(test_dir, target_dir))
            raise Exception('no error raised')
        except zlib.error as e:
            assert str(e).startswith('Error -3 while decompressing')
github nexB / scancode-toolkit / tests / extractcode / test_archive.py View on Github external
def test_uncompress_gzip_basic(self):
        test_file = self.get_test_loc('archive/gzip/file_4.26-1.diff.gz')
        test_dir = self.get_temp_dir()
        archive.uncompress_gzip(test_file, test_dir)
        result = os.path.join(test_dir, 'file_4.26-1.diff.gz-extract')
        assert os.path.exists(result)
github nexB / scancode-toolkit / tests / extractcode / test_archive.py View on Github external
def test_extract_dia_basic(self):
        test_file = self.get_test_loc('archive/dia/dia.dia')
        test_dir = self.get_temp_dir()
        archive.uncompress_gzip(test_file, test_dir)
        result = os.path.join(test_dir, 'dia.dia-extract')
        assert os.path.exists(result)
github nexB / scancode-toolkit / tests / extractcode / test_archive.py View on Github external
def test_uncompress_concatenated_gzip(self):
        # Archive created with:
        # echo "f1content" > f1
        # echo "f2content" > f2
        # gzip -k f1
        # gzip -k -c f2 >> twofiles.gz
        test_file = self.get_test_loc('archive/gzip/twofiles.gz')
        test_dir = self.get_temp_dir()
        warnings = archive.uncompress_gzip(test_file, test_dir)
        result = os.path.join(test_dir, 'twofiles.gz-extract')
        assert os.path.exists(result)
        assert b'f1content\nf2content\n' == open(result, 'rb').read()
        assert [] == warnings
github nexB / scancode-toolkit / tests / extractcode / test_archive.py View on Github external
def test_uncompress_gzip_can_uncompress_windows_ntfs_wmz(self):
        test_file = self.get_test_loc('archive/wmz/image003.wmz')
        test_dir = self.get_temp_dir()
        archive.uncompress_gzip(test_file, test_dir)
        result = os.path.join(test_dir, 'image003.wmz-extract')
        assert os.path.exists(result)
github nexB / scancode-toolkit / tests / extractcode / test_archive.py View on Github external
def test_extract_dia_with_trailing_data(self):
        test_file = self.get_test_loc('archive/dia/dia_trailing.dia')
        test_dir = self.get_temp_dir()
        archive.uncompress_gzip(test_file, test_dir)
        result = os.path.join(test_dir, 'dia_trailing.dia-extract')
        assert os.path.exists(result)
github nexB / scancode-toolkit / tests / extractcode / test_archive.py View on Github external
def test_uncompress_gzip_with_random_data(self):
        test_file = self.get_test_loc('archive/gzip/random_binary.data')
        test_dir = self.get_temp_dir()
        expected = Exception('Not a gzipped file')
        self.assertRaisesInstance(expected, archive.uncompress_gzip, test_file, test_dir)
github nexB / scancode-toolkit / tests / extractcode / test_archive.py View on Github external
def test_extract_dia_broken_3(self):
        test_file = self.get_test_loc('archive/dia/broken/schedulerClassDiagram.dia')
        test_dir = self.get_temp_dir()
        self.assertExceptionContains('invalid distance too far back',
                                     archive.uncompress_gzip,
                                     test_file,
                                     test_dir)
github nexB / scancode-toolkit / tests / extractcode / test_archive.py View on Github external
def test_get_extractors(self):
        test_data = [
            ('archive/zip/basic.zip', [archive.extract_zip]),
            ('archive/rar/basic.rar', [archive.extract_rar]),
            ('archive/deb/adduser_3.112ubuntu1_all.deb', [archive.extract_ar]),
            ('archive/cpio/elfinfo-1.0-1.fc9.src.cpio', [archive.extract_cpio]),
            ('archive/rpm/elfinfo-1.0-1.fc9.src.rpm', [archive.extract_rpm, archive.extract_cpio]),
            ('archive/gzip/file_4.26-1.diff.gz', [archive.uncompress_gzip]),
            ('archive/ar/liby.a', [archive.extract_ar]),
            ('archive/bz2/single_file_not_tarred.bz2', [archive.uncompress_bzip2]),
            ('archive/tar/tarred.tar', [archive.extract_tar]),
            ('archive/tbz/tarred_bzipped.bz', [archive.uncompress_bzip2]),
            ('archive/tbz/tarred_bzipped.tar.bz2', [archive.extract_tar]),
            ('archive/tbz/tarred_bzipped.tbz', [archive.extract_tar]),
            ('archive/tgz/tarred_gzipped.gz', [archive.uncompress_gzip]),
            ('archive/tgz/tarred_gzipped.tar.gz', [archive.extract_tar]),
            ('archive/tgz/tarred_gzipped.tgz', [archive.extract_tar]),
            ('archive/7z/z.7z', [archive.extract_7z]),
            ('archive/Z/tr2tex.Z', [archive.extract_Z, ]),
            ('archive/Z/tkWWW-0.11.tar.Z', [archive.extract_Z, archive.extract_tar]),
            ('archive/xar/xar-1.4.xar', [archive.extract_xarpkg]),
        ]

        for test_file, expected in test_data:
            test_loc = self.get_test_loc(test_file)
            extractors = archive.get_extractors(test_loc)
            assert expected == extractors