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