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


Python TemplatePath.apply_fields方法代码示例

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


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

示例1: test_multi_key_optional

# 需要导入模块: from tank.template import TemplatePath [as 别名]
# 或者: from tank.template.TemplatePath import apply_fields [as 别名]
    def test_multi_key_optional(self):
        """
        Test optional section containing multiple keys.
        """
        definition = "shots/{Shot}[.{branch}.v{version}][.{snapshot}.ma]"
        template_path = TemplatePath(definition, self.keys, self.project_root)

        relative_path = os.path.join("shots",
                                     "s1.mmm.v003.002.ma")

        expected = os.path.join(self.project_root, relative_path)

        fields = { "Shot": "s1",
                   "branch":"mmm",
                   "version": 3,
                   "snapshot": 2}
        result = template_path.apply_fields(fields)
        self.assertEquals(expected, result)

        # if one key from optional section missing, whole section skipped.
        relative_path = os.path.join("shots",
                                     "s1.002.ma")

        expected = os.path.join(self.project_root, relative_path)

        fields = { "Shot": "s1",
                   "branch":"mmm",
                   "snapshot": 2}

        result = template_path.apply_fields(fields)
        self.assertEquals(expected, result)
开发者ID:benoit-leveau,项目名称:tk-core,代码行数:33,代码来源:test_templatepath.py

示例2: test_format_default

# 需要导入模块: from tank.template import TemplatePath [as 别名]
# 或者: from tank.template.TemplatePath import apply_fields [as 别名]
    def test_format_default(self):
        definition = "shots/{Shot}.{branch}.{frame}.ext"
        template = TemplatePath(definition, self.keys, self.project_root)
        fields = { "Shot": "s1",
                   "branch": "loon"}
                   
        # default format
        expected = os.path.join(self.project_root, "shots", "s1.loon.%04d.ext")
        self.assertEquals(expected, template.apply_fields(fields))

        # specify default format
        expected = os.path.join(self.project_root, "shots", "s1.loon.####.ext")
        fields["frame"] = "FORMAT:#"
        self.assertEquals(expected, template.apply_fields(fields))
开发者ID:benoit-leveau,项目名称:tk-core,代码行数:16,代码来源:test_templatepath.py

示例3: test_optional_values

# 需要导入模块: from tank.template import TemplatePath [as 别名]
# 或者: from tank.template.TemplatePath import apply_fields [as 别名]
    def test_optional_values(self):
        definition = "shots/{Sequence}/{Shot}/{Step}/work/{Shot}[.{branch}][.v{version}][.{snapshot}.ma]"
        template_path = TemplatePath(definition, self.keys, self.project_root)

        relative_path = os.path.join("shots",
                                     "seq_1",
                                     "s1",
                                     "Anm",
                                     "work",
                                     "s1.mmm.v003.002.ma")
        expected = os.path.join(self.project_root, relative_path)

        fields = {"Sequence": "seq_1",
                   "Shot": "s1",
                   "Step": "Anm",
                   "branch":"mmm",
                   "version": 3,
                   "snapshot": 2}
        result = template_path.apply_fields(fields)
        self.assertEquals(expected, result)

        # remove optional value
        del(fields["snapshot"])
        relative_path = os.path.join("shots",
                                     "seq_1",
                                     "s1",
                                     "Anm",
                                     "work",
                                     "s1.mmm.v003")
        expected = os.path.join(self.project_root, relative_path)
        result = template_path.apply_fields(fields)
        self.assertEquals(expected, result)


        # remove optional value
        del(fields["branch"])
        relative_path = os.path.join("shots",
                                     "seq_1",
                                     "s1",
                                     "Anm",
                                     "work",
                                     "s1.v003")
        expected = os.path.join(self.project_root, relative_path)
        result = template_path.apply_fields(fields)
        self.assertEquals(expected, result)
开发者ID:benoit-leveau,项目名称:tk-core,代码行数:47,代码来源:test_templatepath.py

示例4: test_good_alphanumeric

# 需要导入模块: from tank.template import TemplatePath [as 别名]
# 或者: from tank.template.TemplatePath import apply_fields [as 别名]
    def test_good_alphanumeric(self):
        """
        Tests applying valid values for alphanumeric key.
        """
        key = StringKey("alpha_num", filter_by="alphanumeric")
        template = TemplatePath("{alpha_num}", {"alpha_num":key}, self.project_root)

        valid_values = ["allChars", "123454", "mixed09", "29mixed", "mi2344xEd", "CAPS"]
        for valid_value in valid_values:
            result = template.apply_fields({"alpha_num": valid_value})
            expected = os.path.join(self.project_root, valid_value)
            self.assertEquals(expected, result)
开发者ID:benoit-leveau,项目名称:tk-core,代码行数:14,代码来源:test_templatepath.py

示例5: test_optional_none_value

# 需要导入模块: from tank.template import TemplatePath [as 别名]
# 或者: from tank.template.TemplatePath import apply_fields [as 别名]
    def test_optional_none_value(self):
        definition = "shots/{Shot}[.{branch}][.v{version}][.{snapshot}.ma]"
        template_path = TemplatePath(definition, self.keys, self.project_root)

        fields = { "Shot": "s1",
                   "branch": None,
                   "version": 3,
                   "snapshot": 2}

        relative_path = os.path.join("shots",
                                     "s1.v003.002.ma")

        expected = os.path.join(self.project_root, relative_path)
        result = template_path.apply_fields(fields)
        self.assertEquals(expected, result)
开发者ID:benoit-leveau,项目名称:tk-core,代码行数:17,代码来源:test_templatepath.py

示例6: test_aliased_key

# 需要导入模块: from tank.template import TemplatePath [as 别名]
# 或者: from tank.template.TemplatePath import apply_fields [as 别名]
    def test_aliased_key(self):
        """
        Apply values to a template which has an aliased key.
        """
        key = IntegerKey("aliased_name")
        keys = {"initial_name": key}
        definition = "{initial_name}"
        template = TemplatePath(definition, keys, self.project_root)

        expected = os.path.join(self.project_root, "2")
        fields = {"aliased_name": 2}
        self.assertEquals(expected, template.apply_fields(fields))

        fields = {"initial_name": 2}
        self.assertRaises(TankError, template.apply_fields, fields)
开发者ID:benoit-leveau,项目名称:tk-core,代码行数:17,代码来源:test_templatepath.py

示例7: test_default

# 需要导入模块: from tank.template import TemplatePath [as 别名]
# 或者: from tank.template.TemplatePath import apply_fields [as 别名]
 def test_default(self):
     template = TemplatePath("{Shot}/{Step}/file.ex", self.keys, self.project_root)
     expected = os.path.join(self.project_root, "s1", "Anm", "file.ex")
     fields = {"Step": "Anm"}
     result = template.apply_fields(fields)
     self.assertEquals(expected, result)
开发者ID:benoit-leveau,项目名称:tk-core,代码行数:8,代码来源:test_templatepath.py


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