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


Python Environment.list方法代码示例

本文整理汇总了Python中gears.environment.Environment.list方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.list方法的具体用法?Python Environment.list怎么用?Python Environment.list使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gears.environment.Environment的用法示例。


在下文中一共展示了Environment.list方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: EnvironmentListTests

# 需要导入模块: from gears.environment import Environment [as 别名]
# 或者: from gears.environment.Environment import list [as 别名]
class EnvironmentListTests(TestCase):
    def setUp(self):
        self.environment = Environment(STATIC_DIR)
        self.environment.register_defaults()
        self.environment.finders.register(FileSystemFinder([ASSETS_DIR]))

    def test_list(self):
        items = list(self.environment.list("js/templates", "application/javascript"))
        self.assertEqual(len(items), 3)
        for i, item in enumerate(sorted(items, key=lambda x: x[1])):
            path = "js/templates/%s.js.handlebars" % "abc"[i]
            asset_attributes, absolute_path = item
            self.assertIsInstance(asset_attributes, AssetAttributes)
            self.assertEqual(asset_attributes.path, path)
            self.assertEqual(absolute_path, os.path.join(ASSETS_DIR, path))

    def test_list_recursively(self):
        items = list(self.environment.list("js/templates", "application/javascript", recursive=True))
        self.assertEqual(len(items), 4)
        for i, item in enumerate(sorted(items, key=lambda x: x[1])):
            path = "js/templates/%s.js.handlebars" % ("a", "b", "c", "d/e")[i]
            asset_attributes, absolute_path = item
            self.assertIsInstance(asset_attributes, AssetAttributes)
            self.assertEqual(asset_attributes.path, path)
            self.assertEqual(absolute_path, os.path.join(ASSETS_DIR, path))
开发者ID:jjay,项目名称:gears,代码行数:27,代码来源:test_environment.py

示例2: EnvironmentListTests

# 需要导入模块: from gears.environment import Environment [as 别名]
# 或者: from gears.environment.Environment import list [as 别名]
class EnvironmentListTests(TestCase):

    def setUp(self):
        self.environment = Environment(STATIC_DIR)
        self.environment.register_defaults()
        self.environment.finders.register(FileSystemFinder([ASSETS_DIR]))

    def test_list(self):
        items = list(self.environment.list('js/templates', ['.js', '.handlebars']))
        self.assertEqual(len(items), 3)
        for i, item in enumerate(sorted(items, key=lambda x: x[1])):
            path = 'js/templates/%s.js.handlebars' % 'abc'[i]
            asset_attributes, absolute_path = item
            self.assertIsInstance(asset_attributes, AssetAttributes)
            self.assertEqual(asset_attributes.path, path)
            self.assertEqual(absolute_path, os.path.join(ASSETS_DIR, path))
开发者ID:xobb1t,项目名称:gears,代码行数:18,代码来源:test_environment.py


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