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


Python Language.find_by_name方法代碼示例

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


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

示例1: test_find

# 需要導入模塊: from libs.language import Language [as 別名]
# 或者: from libs.language.Language import find_by_name [as 別名]
 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,代碼行數:12,代碼來源:test_language.py

示例2: classify_ambiguous_languages

# 需要導入模塊: from libs.language import Language [as 別名]
# 或者: from libs.language.Language import find_by_name [as 別名]
        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,代碼行數:10,代碼來源:test_classifier.py

示例3: test_programming

# 需要導入模塊: from libs.language import Language [as 別名]
# 或者: from libs.language.Language import find_by_name [as 別名]
 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,代碼行數:9,代碼來源:test_language.py

示例4: test_primary_extension

# 需要導入模塊: from libs.language import Language [as 別名]
# 或者: from libs.language.Language import find_by_name [as 別名]
    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,代碼行數:15,代碼來源:test_language.py

示例5: test_find_by_filename

# 需要導入模塊: from libs.language import Language [as 別名]
# 或者: from libs.language.Language import find_by_name [as 別名]
 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,代碼行數:18,代碼來源:test_language.py

示例6: test_linguist_language

# 需要導入模塊: from libs.language import Language [as 別名]
# 或者: from libs.language.Language import find_by_name [as 別名]
 def test_linguist_language(self):
     assert self.linguist_repo().language == Language.find_by_name('Python')
開發者ID:arthur503,項目名稱:linguist,代碼行數:4,代碼來源:test_repository.py

示例7: test_colorize

# 需要導入模塊: from libs.language import Language [as 別名]
# 或者: from libs.language.Language import find_by_name [as 別名]
 def test_colorize(self):
     assert colorize == Language.find_by_name('Ruby').colorize("def foo\n  'foo'\nend\n")
開發者ID:arthur503,項目名稱:linguist,代碼行數:4,代碼來源:test_language.py

示例8: test_wrap

# 需要導入模塊: from libs.language import Language [as 別名]
# 或者: from libs.language.Language import find_by_name [as 別名]
 def test_wrap(self):
     assert False == Language.find_by_name('C').wrap
     assert True == Language.find_by_name('Markdown').wrap
開發者ID:arthur503,項目名稱:linguist,代碼行數:5,代碼來源:test_language.py

示例9: test_ace_mode

# 需要導入模塊: from libs.language import Language [as 別名]
# 或者: from libs.language.Language import find_by_name [as 別名]
 def test_ace_mode(self):
     assert 'c_cpp' == Language.find_by_name('C++').ace_mode
     assert 'coffee' == Language.find_by_name('CoffeeScript').ace_mode
     assert 'csharp' == Language.find_by_name('C#').ace_mode
     assert 'css' == Language.find_by_name('CSS').ace_mode
     assert 'javascript' == Language.find_by_name('JavaScript').ace_mode
開發者ID:arthur503,項目名稱:linguist,代碼行數:8,代碼來源:test_language.py

示例10: test_popular

# 需要導入模塊: from libs.language import Language [as 別名]
# 或者: from libs.language.Language import find_by_name [as 別名]
 def test_popular(self):
     assert Language.find_by_name('Ruby').is_popular
     assert Language.find_by_name('Perl').is_popular
     assert Language.find_by_name('Python').is_popular
     assert Language.find_by_name('Assembly').is_unpopular
     assert Language.find_by_name('Brainfuck').is_unpopular
開發者ID:arthur503,項目名稱:linguist,代碼行數:8,代碼來源:test_language.py

示例11: test_lexer

# 需要導入模塊: from libs.language import Language [as 別名]
# 或者: from libs.language.Language import find_by_name [as 別名]
 def test_lexer(self):
     assert find_lexer_class('ActionScript 3') == Language.find_by_name('ActionScript').lexer
     assert find_lexer_class('ActionScript 3') == Language.find_by_name('ActionScript').lexer
     assert find_lexer_class('Bash') == Language.find_by_name('Gentoo Ebuild').lexer
     assert find_lexer_class('Bash') == Language.find_by_name('Gentoo Eclass').lexer
     assert find_lexer_class('Bash') == Language.find_by_name('Shell').lexer
     assert find_lexer_class('C') == Language.find_by_name('OpenCL').lexer
     assert find_lexer_class('C') == Language.find_by_name('XS').lexer
     assert find_lexer_class('C++') == Language.find_by_name('C++').lexer
     assert find_lexer_class('Coldfusion HTML') == Language.find_by_name('ColdFusion').lexer
     assert find_lexer_class('Coq') == Language.find_by_name('Coq').lexer
     assert find_lexer_class('FSharp') == Language.find_by_name('F#').lexer
     assert find_lexer_class('FSharp') == Language.find_by_name('F#').lexer
     assert find_lexer_class('Fortran') == Language.find_by_name('FORTRAN').lexer
     assert find_lexer_class('Gherkin') == Language.find_by_name('Cucumber').lexer
     assert find_lexer_class('Groovy') == Language.find_by_name('Groovy').lexer
     assert find_lexer_class('HTML') == Language.find_by_name('HTML').lexer
     assert find_lexer_class('HTML+Django/Jinja') == Language.find_by_name('HTML+Django').lexer
     assert find_lexer_class('HTML+PHP') == Language.find_by_name('HTML+PHP').lexer
     assert find_lexer_class('HTTP') == Language.find_by_name('HTTP').lexer
     assert find_lexer_class('JSON') == Language.find_by_name('JSON').lexer
     assert find_lexer_class('Java') == Language.find_by_name('ChucK').lexer
     assert find_lexer_class('Java') == Language.find_by_name('Java').lexer
     assert find_lexer_class('JavaScript') == Language.find_by_name('JavaScript').lexer
     assert find_lexer_class('MOOCode') == Language.find_by_name('Moocode').lexer
     assert find_lexer_class('MuPAD') == Language.find_by_name('mupad').lexer
     assert find_lexer_class('NASM') == Language.find_by_name('Assembly').lexer
     assert find_lexer_class('OCaml') == Language.find_by_name('OCaml').lexer
     assert find_lexer_class('Ooc') == Language.find_by_name('ooc').lexer
     assert find_lexer_class('OpenEdge ABL') == Language.find_by_name('OpenEdge ABL').lexer
     assert find_lexer_class('REBOL') == Language.find_by_name('Rebol').lexer
     assert find_lexer_class('RHTML') == Language.find_by_name('HTML+ERB').lexer
     assert find_lexer_class('RHTML') == Language.find_by_name('RHTML').lexer
     assert find_lexer_class('Ruby') == Language.find_by_name('Mirah').lexer
     assert find_lexer_class('Ruby') == Language.find_by_name('Ruby').lexer
     assert find_lexer_class('S') == Language.find_by_name('R').lexer
     assert find_lexer_class('Scheme') == Language.find_by_name('Emacs Lisp').lexer
     assert find_lexer_class('Scheme') == Language.find_by_name('Nu').lexer
     assert find_lexer_class('Racket') == Language.find_by_name('Racket').lexer
     assert find_lexer_class('Scheme') == Language.find_by_name('Scheme').lexer
     assert find_lexer_class('Standard ML') == Language.find_by_name('Standard ML').lexer
     assert find_lexer_class('TeX') == Language.find_by_name('TeX').lexer
     #FIXME bug by pygments
     # assert find_lexer_class('Verilog') == Language.find_by_name('Verilog').lexer
     assert find_lexer_class('XSLT') == Language.find_by_name('XSLT').lexer
     assert find_lexer_class('aspx-vb') == Language.find_by_name('ASP').lexer
     assert find_lexer_class('haXe') == Language.find_by_name('Haxe').lexer
     assert find_lexer_class('reStructuredText') == Language.find_by_name('reStructuredText').lexer
開發者ID:arthur503,項目名稱:linguist,代碼行數:50,代碼來源:test_language.py

示例12: test_search_term

# 需要導入模塊: from libs.language import Language [as 別名]
# 或者: from libs.language.Language import find_by_name [as 別名]
    def test_search_term(self):
        assert 'perl' == Language.find_by_name('Perl').search_term
        assert 'python' == Language.find_by_name('Python').search_term
        assert 'ruby' == Language.find_by_name('Ruby').search_term
        assert 'common-lisp' == Language.find_by_name('Common Lisp').search_term
        assert 'html+erb' == Language.find_by_name('HTML+ERB').search_term
        assert 'max/msp' == Language.find_by_name('Max').search_term
        assert 'puppet' == Language.find_by_name('Puppet').search_term
        assert 'pure-data' == Language.find_by_name('Pure Data').search_term

        assert 'aspx-vb' == Language.find_by_name('ASP').search_term
        assert 'as3' == Language.find_by_name('ActionScript').search_term
        assert 'nasm' == Language.find_by_name('Assembly').search_term
        assert 'bat' == Language.find_by_name('Batchfile').search_term
        assert 'csharp' == Language.find_by_name('C#').search_term
        assert 'cpp' == Language.find_by_name('C++').search_term
        assert 'cfm' == Language.find_by_name('ColdFusion').search_term
        assert 'dpatch' == Language.find_by_name('Darcs Patch').search_term
        assert 'ocaml' == Language.find_by_name('F#').search_term
        assert 'pot' == Language.find_by_name('Gettext Catalog').search_term
        assert 'irc' == Language.find_by_name('IRC log').search_term
        assert 'lhs' == Language.find_by_name('Literate Haskell').search_term
        assert 'ruby' == Language.find_by_name('Mirah').search_term
        assert 'raw' == Language.find_by_name('Raw token data').search_term
        assert 'bash' == Language.find_by_name('Shell').search_term
        assert 'vim' == Language.find_by_name('VimL').search_term
        assert 'jsp' == Language.find_by_name('Java Server Pages').search_term
        assert 'rst' == Language.find_by_name('reStructuredText').search_term
開發者ID:arthur503,項目名稱:linguist,代碼行數:30,代碼來源:test_language.py

示例13: test_groups

# 需要導入模塊: from libs.language import Language [as 別名]
# 或者: from libs.language.Language import find_by_name [as 別名]
    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,代碼行數:23,代碼來源:test_language.py

示例14: test_binary_override

# 需要導入模塊: from libs.language import Language [as 別名]
# 或者: from libs.language.Language import find_by_name [as 別名]
 def test_binary_override(self):
     assert self.repo(ROOT_DIR + '/samples/Nimrod').language == Language.find_by_name('Nimrod')
開發者ID:arthur503,項目名稱:linguist,代碼行數:4,代碼來源:test_repository.py

示例15: test_linguist_languages

# 需要導入模塊: from libs.language import Language [as 別名]
# 或者: from libs.language.Language import find_by_name [as 別名]
 def test_linguist_languages(self):
     assert self.linguist_repo().languages[Language.find_by_name('Python')] > 2000
開發者ID:arthur503,項目名稱:linguist,代碼行數:4,代碼來源:test_repository.py


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