How to use the extractcode.archive.get_extractors 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 / extractcode_assert_utils.py View on Github external
def check_get_extractors(self, test_file, expected, kinds=()):
        from extractcode import archive

        test_loc = self.get_test_loc(test_file)
        if kinds:
            extractors = archive.get_extractors(test_loc, kinds)
        else:
            extractors = archive.get_extractors(test_loc)

        # import typecode
        # ft = 'TODO' or typecode.contenttype.get_type(test_loc).filetype_file
        # mt = 'TODO' or typecode.contenttype.get_type(test_loc).mimetype_file
        fe = fileutils.file_extension(test_loc).lower()
        em = ', '.join(e.__module__ + '.' + e.__name__ for e in extractors)

        msg = ('%(expected)r == %(extractors)r for %(test_file)s\n'
               'with fe:%(fe)r, em:%(em)s' % locals())
        assert expected == extractors, msg
github nexB / scancode-toolkit / tests / extractcode / extractcode_assert_utils.py View on Github external
def check_get_extractors(self, test_file, expected, kinds=()):
        from extractcode import archive

        test_loc = self.get_test_loc(test_file)
        if kinds:
            extractors = archive.get_extractors(test_loc, kinds)
        else:
            extractors = archive.get_extractors(test_loc)

        # import typecode
        # ft = 'TODO' or typecode.contenttype.get_type(test_loc).filetype_file
        # mt = 'TODO' or typecode.contenttype.get_type(test_loc).mimetype_file
        fe = fileutils.file_extension(test_loc).lower()
        em = ', '.join(e.__module__ + '.' + e.__name__ for e in extractors)

        msg = ('%(expected)r == %(extractors)r for %(test_file)s\n'
               'with fe:%(fe)r, em:%(em)s' % locals())
        assert expected == extractors, msg
github nexB / scancode-toolkit / tests / extractcode / test_archive.py View on Github external
def test_windows_ntfs_wmz_are_sometimes_gzip(self):
        test_file = self.get_test_loc('archive/wmz/image003.wmz')
        extractors = archive.get_extractors(test_file)
        assert [archive.uncompress_gzip] == extractors
github nexB / scancode-toolkit / tests / extractcode / test_archive.py View on Github external
('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
github nexB / scancode-toolkit / tests / extractcode / test_archive.py View on Github external
def test_get_extractors_with_kinds(self):
        test_data = [
            ('archive/deb/adduser_3.112ubuntu1_all.deb', []),
            ('archive/rpm/elfinfo-1.0-1.fc9.src.rpm', []),
            ('archive/ar/liby.a', []),
            ('archive/tar/tarred.tar', [archive.extract_tar]),
            ('archive/tbz/tarred_bzipped.tar.bz2', []),
        ]

        kinds = (archive.regular, archive.file_system, archive.docs)
        for test_file, expected in test_data:
            test_loc = self.get_test_loc(test_file)
            extractors = archive.get_extractors(test_loc, kinds)

            ft = typecode.contenttype.get_type(test_loc).filetype_file
            mt = typecode.contenttype.get_type(test_loc).mimetype_file
            fe = fileutils.file_extension(test_loc).lower()
            msg = ('%(expected)r == %(extractors)r for %(test_file)s\n'
                   'with ft:%(ft)r, mt:%(mt)r, fe:%(fe)r' % locals())
            assert expected == extractors, msg
github nexB / scancode-toolkit / tests / extractcode / test_archive.py View on Github external
def test_windows_media_player_skins_are_zip(self):
        test_file = self.get_test_loc('archive/wmz/Go.wmz')
        extractors = archive.get_extractors(test_file)
        assert [archive.extract_zip] == extractors