當前位置: 首頁>>代碼示例>>Python>>正文


Python language.Language類代碼示例

本文整理匯總了Python中libs.language.Language的典型用法代碼示例。如果您正苦於以下問題:Python Language類的具體用法?Python Language怎麽用?Python Language使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Language類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: classify_ambiguous_languages

        def classify_ambiguous_languages(sample):
            language = Language.find_by_name(sample['language'])
            languages = Language.find_by_filename(sample['path'])
            languages_names = [x.name for x in languages]

            results = Classifier.classify(DATA, open(sample['path']).read(), languages_names)

            self.assertEqual(language.name, results[0][0])
開發者ID:kkszysiu,項目名稱:linguist,代碼行數:8,代碼來源:test_classifier.py

示例2: test_find

 def test_find(self):
     assert 'Ruby' == Language.find_by_name('Ruby').name
     assert 'Ruby' == Language.find_by_name('ruby').name
     assert 'C++' == Language.find_by_name('C++').name
     assert 'C++' == Language.find_by_name('c++').name
     assert 'C++' == Language.find_by_name('cpp').name
     assert 'C#' == Language.find_by_name('C#').name
     assert 'C#' == Language.find_by_name('c#').name
     assert 'C#' == Language.find_by_name('csharp').name
     assert None == Language.find_by_name('defunkt')
開發者ID:arthur503,項目名稱:linguist,代碼行數:10,代碼來源:test_language.py

示例3: test_find_by_shebang

    def test_find_by_shebang(self):
        assert 'ruby' == Samples.interpreter_from_shebang("#!/usr/bin/ruby\n# baz")

        for key, shebangs in self.SHEBANG_EXAMPLES.iteritems():
            for shebang in shebangs:
                language = Language.find_by_shebang(shebang)
                print Language[key], language
                if key is None:
                    self.assertEqual(Language[key], language)
                else:
                    self.assertTrue(Language[key] in language)
開發者ID:kkszysiu,項目名稱:linguist,代碼行數:11,代碼來源:test_language.py

示例4: test_primary_extension

    def test_primary_extension(self):
        assert '.pl' == Language.find_by_name('Perl').primary_extension
        assert '.py' == Language.find_by_name('Python').primary_extension
        assert '.rb' == Language.find_by_name('Ruby').primary_extension
        assert '.js' == Language.find_by_name('JavaScript').primary_extension
        assert '.coffee' == Language.find_by_name('CoffeeScript').primary_extension
        assert '.t' == Language.find_by_name('Turing').primary_extension
        assert '.ts' == Language.find_by_name('TypeScript').primary_extension

        # This is a nasty requirement, but theres some code in GitHub that
        # expects this. Really want to drop this.
        for language in Language.all():
          assert language.primary_extension, "%s has no primary extension" % language
開發者ID:arthur503,項目名稱:linguist,代碼行數:13,代碼來源:test_language.py

示例5: test_programming

 def test_programming(self):
     assert 'programming' == Language.find_by_name('JavaScript').type
     assert 'programming' == Language.find_by_name('Perl').type
     assert 'programming' == Language.find_by_name('PowerShell').type
     assert 'programming' == Language.find_by_name('Python').type
     assert 'programming' == Language.find_by_name('Ruby').type
     assert 'programming' == Language.find_by_name('TypeScript').type
開發者ID:arthur503,項目名稱:linguist,代碼行數:7,代碼來源:test_language.py

示例6: test_primary_extension

    def test_primary_extension(self):
        assert ".pl" == Language["Perl"].primary_extension
        assert ".py" == Language["Python"].primary_extension
        assert ".rb" == Language["Ruby"].primary_extension
        assert ".js" == Language["JavaScript"].primary_extension
        assert ".coffee" == Language["CoffeeScript"].primary_extension
        assert ".t" == Language["Turing"].primary_extension
        assert ".ts" == Language["TypeScript"].primary_extension

        # This is a nasty requirement, but theres some code in GitHub that
        # expects this. Really want to drop this.
        for language in Language.all():
            assert language.primary_extension, "%s has no primary extension" % language
開發者ID:mrajashree,項目名稱:linguist,代碼行數:13,代碼來源:test_language.py

示例7: test_groups

    def test_groups(self):
        # Test a couple identity cases
        assert Language['Perl'] == Language['Perl'].group
        assert Language['Python'] == Language['Python'].group
        assert Language['Ruby'] == Language['Ruby'].group

        # Test a few special groups
        assert Language['Assembly'] == Language['GAS'].group
        assert Language['C'] == Language['OpenCL'].group
        assert Language['Haskell'] == Language['Literate Haskell'].group
        assert Language['Java'] == Language['Java Server Pages'].group
        assert Language['Python'] == Language['Cython'].group
        assert Language['Python'] == Language['NumPy'].group
        assert Language['Shell'] == Language['Batchfile'].group
        assert Language['Shell'] == Language['Gentoo Ebuild'].group
        assert Language['Shell'] == Language['Gentoo Eclass'].group
        assert Language['Shell'] == Language['Tcsh'].group

        # Ensure everyone has a group
        for language in Language.all():
            assert language.group, "%s has no group" % language
開發者ID:tclh123,項目名稱:linguist,代碼行數:21,代碼來源:test_language.py

示例8: test_color

 def test_color(self):
     assert '#701516' == Language.find_by_name('Ruby').color
     assert '#3581ba' == Language.find_by_name('Python').color
     assert '#f15501' == Language.find_by_name('JavaScript').color
     assert '#31859c' == Language.find_by_name('TypeScript').color
開發者ID:arthur503,項目名稱:linguist,代碼行數:5,代碼來源:test_language.py

示例9: test_colors

 def test_colors(self):
     Language['Ruby'] in Language.colors()
     Language['Python'] in Language.colors()
開發者ID:tclh123,項目名稱:linguist,代碼行數:3,代碼來源:test_language.py

示例10: test_escaped_name

 def test_escaped_name(self):
     assert 'C', Language.find_by_name('C').escaped_name
     assert 'C%23', Language.find_by_name('C#').escaped_name
     assert 'C%2B%2B', Language.find_by_name('C++').escaped_name
     assert 'Objective-C', Language.find_by_name('Objective-C').escaped_name
     assert 'Common%20Lisp', Language.find_by_name('Common Lisp').escaped_name
開發者ID:arthur503,項目名稱:linguist,代碼行數:6,代碼來源:test_language.py

示例11: test_find_all_by_alias

 def test_find_all_by_alias(self):
     for language in Language.all():
         for name in language.aliases:
             assert language == Language.find_by_alias(name)
開發者ID:arthur503,項目名稱:linguist,代碼行數:4,代碼來源:test_language.py

示例12: test_find_by_filename

 def test_find_by_filename(self):
     assert [Language.find_by_name('Shell')] == Language.find_by_filename('PKGBUILD')
     assert [Language.find_by_name('Ruby')] == Language.find_by_filename('foo.rb')
     assert [Language.find_by_name('Ruby')] == Language.find_by_filename('foo/bar.rb')
     assert [Language.find_by_name('Ruby')] == Language.find_by_filename('Rakefile')
     assert [Language.find_by_name('Ruby')] == Language.find_by_filename('PKGBUILD.rb')
     assert Language.find_by_name('ApacheConf') == Language.find_by_filename('httpd.conf')[0]
     assert [Language.find_by_name('ApacheConf')] == Language.find_by_filename('.htaccess')
     assert Language.find_by_name('Nginx') == Language.find_by_filename('nginx.conf')[0]
     assert ['C', 'C++', 'Objective-C'] == sorted(map(lambda l: l.name, Language.find_by_filename('foo.h')))
     assert [] == Language.find_by_filename('rb')
     assert [] == Language.find_by_filename('.rb')
     assert [] == Language.find_by_filename('.nkt')
     assert [Language.find_by_name('Shell')] == Language.find_by_filename('.bashrc')
     assert [Language.find_by_name('Shell')] == Language.find_by_filename('bash_profile')
     assert [Language.find_by_name('Shell')] == Language.find_by_filename('.zshrc')
開發者ID:arthur503,項目名稱:linguist,代碼行數:16,代碼來源:test_language.py

示例13: test_ace_modes

 def test_ace_modes(self):
     assert Language['Ruby'] in Language.ace_modes()
     assert Language['FORTRAN'] not in Language.ace_modes()
開發者ID:tclh123,項目名稱:linguist,代碼行數:3,代碼來源:test_language.py

示例14: test_find_all_by_name

 def test_find_all_by_name(self):
     for language in Language.all():
         assert language == Language.find_by_name(language.name)
         assert language == Language.name_index[language.name]
開發者ID:arthur503,項目名稱:linguist,代碼行數:4,代碼來源:test_language.py

示例15: test_groups

    def test_groups(self):
        # Test a couple identity cases
        assert Language.find_by_name('Perl') == Language.find_by_name('Perl').group
        assert Language.find_by_name('Python') == Language.find_by_name('Python').group
        assert Language.find_by_name('Ruby') == Language.find_by_name('Ruby').group

        # Test a few special groups
        assert Language.find_by_name('Assembly') == Language.find_by_name('GAS').group
        assert Language.find_by_name('C') == Language.find_by_name('OpenCL').group
        assert Language.find_by_name('Haskell') == Language.find_by_name('Literate Haskell').group
        assert Language.find_by_name('Java') == Language.find_by_name('Java Server Pages').group
        assert Language.find_by_name('Python') == Language.find_by_name('Cython').group
        assert Language.find_by_name('Python') == Language.find_by_name('NumPy').group
        assert Language.find_by_name('Shell') == Language.find_by_name('Batchfile').group
        assert Language.find_by_name('Shell') == Language.find_by_name('Gentoo Ebuild').group
        assert Language.find_by_name('Shell') == Language.find_by_name('Gentoo Eclass').group
        assert Language.find_by_name('Shell') == Language.find_by_name('Tcsh').group

        # Ensure everyone has a group
        for language in Language.all():
            assert language.group, "%s has no group" % language
開發者ID:arthur503,項目名稱:linguist,代碼行數:21,代碼來源:test_language.py


注:本文中的libs.language.Language類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。