How to use the commoncode.fileutils.file_extension function in commoncode

To help you get started, we’ve selected a few commoncode 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 / commoncode / test_fileutils.py View on Github external
def test_file_extension_on_path_and_location_6(self):
        test_dir = self.get_test_loc('fileutils/basename')
        test_file = 'a/f.a'
        expected_name = '.a'
        result = fileutils.file_extension(test_file)
        assert expected_name == result
        result = fileutils.file_extension((os.path.join(test_dir, test_file)))
        assert expected_name == result
github nexB / scancode-toolkit / tests / commoncode / test_fileutils.py View on Github external
def test_file_extension_on_path_and_location_5(self):
        test_dir = self.get_test_loc('fileutils/basename')
        test_file = 'a/b/'
        expected_name = ''
        result = fileutils.file_extension(test_file)
        assert expected_name == result
        result = fileutils.file_extension((os.path.join(test_dir, test_file)))
        assert expected_name == result
github nexB / scancode-toolkit / tests / commoncode / test_fileutils.py View on Github external
def test_file_extension_on_path_and_location_8(self):
        test_dir = self.get_test_loc('fileutils/basename')
        test_file = 'f.a/a.c'
        expected_name = '.c'
        result = fileutils.file_extension(test_file)
        assert expected_name == result
        result = fileutils.file_extension((os.path.join(test_dir, test_file)))
        assert expected_name == result
github nexB / scancode-toolkit / tests / commoncode / test_fileutils.py View on Github external
def test_file_extension_on_path_and_location_2(self):
        test_dir = self.get_test_loc('fileutils/basename')
        test_file = 'a/.a/'
        expected_name = ''
        result = fileutils.file_extension(test_file)
        assert expected_name == result
        result = fileutils.file_extension((os.path.join(test_dir, test_file)))
        assert expected_name == result
github nexB / scancode-toolkit / tests / commoncode / test_fileutils.py View on Github external
def test_file_extension_on_path_and_location_3(self):
        test_dir = self.get_test_loc('fileutils/basename')
        test_file = 'a/b/.a.b'
        expected_name = '.b'
        result = fileutils.file_extension(test_file)
        assert expected_name == result
        result = fileutils.file_extension((os.path.join(test_dir, test_file)))
        assert expected_name == result
github nexB / scancode-toolkit / tests / commoncode / test_fileutils.py View on Github external
def test_file_extension_on_path_and_location_1(self):
        test_dir = self.get_test_loc('fileutils/basename')
        test_file = 'a/.a/file'
        expected_name = ''
        result = fileutils.file_extension(test_file)
        assert expected_name == result
        result = fileutils.file_extension((os.path.join(test_dir, test_file)))
        assert expected_name == result
github nexB / scancode-toolkit / tests / commoncode / test_fileutils.py View on Github external
def test_file_extension_on_path_and_location_4(self):
        test_dir = self.get_test_loc('fileutils/basename')
        test_file = 'a/b/a.tag.gz'
        expected_name = '.gz'
        result = fileutils.file_extension(test_file)
        assert expected_name == result
        result = fileutils.file_extension((os.path.join(test_dir, test_file)))
        assert expected_name == result
github nexB / scancode-toolkit / tests / commoncode / test_fileutils.py View on Github external
def test_file_extension_on_path_and_location_3(self):
        test_dir = self.get_test_loc('fileutils/basename')
        test_file = 'a/b/.a.b'
        expected_name = '.b'
        result = fileutils.file_extension(test_file)
        assert expected_name == result
        result = fileutils.file_extension((os.path.join(test_dir, test_file)))
        assert expected_name == result
github nexB / scancode-toolkit / tests / commoncode / test_fileutils.py View on Github external
def test_file_extension_on_path_and_location_1(self):
        test_dir = self.get_test_loc('fileutils/basename')
        test_file = 'a/.a/file'
        expected_name = ''
        result = fileutils.file_extension(test_file)
        assert expected_name == result
        result = fileutils.file_extension((os.path.join(test_dir, test_file)))
        assert expected_name == result