本文整理汇总了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')
示例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])
示例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
示例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
示例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')
示例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')
示例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")
示例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
示例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
示例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
示例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
示例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
示例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
示例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')
示例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