本文整理汇总了Python中libs.language.Language.find_by_filename方法的典型用法代码示例。如果您正苦于以下问题:Python Language.find_by_filename方法的具体用法?Python Language.find_by_filename怎么用?Python Language.find_by_filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libs.language.Language
的用法示例。
在下文中一共展示了Language.find_by_filename方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: classify_ambiguous_languages
# 需要导入模块: from libs.language import Language [as 别名]
# 或者: from libs.language.Language import find_by_filename [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])
示例2: test_find_by_filename
# 需要导入模块: from libs.language import Language [as 别名]
# 或者: from libs.language.Language import find_by_filename [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')
示例3: test_find_by_filename
# 需要导入模块: from libs.language import Language [as 别名]
# 或者: from libs.language.Language import find_by_filename [as 别名]
def test_find_by_filename(self):
assert [Language['Shell']] == Language.find_by_filename('PKGBUILD')
assert [Language['Ruby']] == Language.find_by_filename('foo.rb')
assert [Language['Ruby']] == Language.find_by_filename('foo/bar.rb')
assert [Language['Ruby']] == Language.find_by_filename('Rakefile')
assert [Language['Ruby']] == Language.find_by_filename('PKGBUILD.rb')
assert Language['ApacheConf'] == Language.find_by_filename('httpd.conf')[0]
assert [Language['ApacheConf']] == Language.find_by_filename('.htaccess')
assert Language['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['Shell']] == Language.find_by_filename('.bashrc')
assert [Language['Shell']] == Language.find_by_filename('bash_profile')
assert [Language['Shell']] == Language.find_by_filename('.zshrc')
assert [Language['Clojure']] == Language.find_by_filename('riemann.config')
assert [Language['HTML+Django']] == Language.find_by_filename('index.jinja')