当前位置: 首页>>代码示例>>Python>>正文


Python Language.find_by_filename方法代码示例

本文整理汇总了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])
开发者ID:kkszysiu,项目名称:linguist,代码行数:10,代码来源:test_classifier.py

示例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')
开发者ID:arthur503,项目名称:linguist,代码行数:18,代码来源:test_language.py

示例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')
开发者ID:tclh123,项目名称:linguist,代码行数:20,代码来源:test_language.py


注:本文中的libs.language.Language.find_by_filename方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。