當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。