當前位置: 首頁>>代碼示例>>Python>>正文


Python template.TemplatePath類代碼示例

本文整理匯總了Python中tank.template.TemplatePath的典型用法代碼示例。如果您正苦於以下問題:Python TemplatePath類的具體用法?Python TemplatePath怎麽用?Python TemplatePath使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TemplatePath類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_multi_key_optional

    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,代碼行數:31,代碼來源:test_templatepath.py

示例2: test_one_key

 def test_one_key(self):
     definition = "{Shot}/boo.wtf"
     template = TemplatePath(definition, self.keys, root_path=self.project_root)
     relative_path = os.path.join("shot_1", "boo.wtf")
     file_path = os.path.join(self.project_root, relative_path)
     expected = {"Shot": "shot_1"}
     result = template.get_fields(file_path)
     self.assertEquals(result, expected)
開發者ID:benoit-leveau,項目名稱:tk-core,代碼行數:8,代碼來源:test_templatepath.py

示例3: test_skip_enum

 def test_skip_enum(self):
     expected = os.path.join(self.project_root, "*")
     key = StringKey("Shot", choices=["s1", "s2"])
     template = TemplatePath("{Shot}", {"Shot":key}, self.project_root)
     fields = {"Shot":"*"}
     skip_fields = ["Shot"]
     result = template._apply_fields(fields, ignore_types=skip_fields)
     self.assertEquals(expected, result)
開發者ID:benoit-leveau,項目名稱:tk-core,代碼行數:8,代碼來源:test_templatepath.py

示例4: test_valid_alphanumeric

 def test_valid_alphanumeric(self):
     """Bug reported in Ticket #17090"""
     template = TemplatePath("{branch}.v{version}.nk", self.keys, self.project_root)
     input_path = os.path.join(self.project_root, "comp.v001.nk")
     expected = {"branch": "comp",
                 "version": 1}
     result = template.get_fields(input_path)
     self.assertEquals(expected, result)
開發者ID:benoit-leveau,項目名稱:tk-core,代碼行數:8,代碼來源:test_templatepath.py

示例5: test_optional_sections

    def test_optional_sections(self):
        """
        Test that definition using optional sections resolves for missing optional values.
        """
        definition = "shots/{Sequence}/{Shot}/{Step}/work/{Shot}[.{branch}][.v{version}][.{snapshot}.ma]"
        template = TemplatePath(definition, self.keys, self.project_root)

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

        expected = {"Sequence": "seq_1",
                    "Shot": "s1",
                    "Step": "Anm",
                    "branch":"mmm",
                    "version": 3,
                    "snapshot": 2}

        result = template.get_fields(input_path)
        self.assertEqual(expected, result)

        # remove version value
        relative_path = os.path.join("shots",
                                     "seq_1",
                                     "s1",
                                     "Anm",
                                     "work",
                                     "s1.mmm.002.ma")
        input_path = os.path.join(self.project_root, relative_path)

        expected = {"Sequence": "seq_1",
                    "Shot": "s1",
                    "Step": "Anm",
                    "branch":"mmm",
                    "snapshot": 2}

        result = template.get_fields(input_path)
        self.assertEqual(expected, result)

        # remove all optional values
        relative_path = os.path.join("shots",
                                     "seq_1",
                                     "s1",
                                     "Anm",
                                     "work",
                                     "s1")
        input_path = os.path.join(self.project_root, relative_path)

        expected = {"Sequence": "seq_1",
                    "Shot": "s1",
                    "Step": "Anm"}

        result = template.get_fields(input_path)
        self.assertEqual(expected, result)
開發者ID:benoit-leveau,項目名稱:tk-core,代碼行數:58,代碼來源:test_templatepath.py

示例6: test_aliased_key

 def test_aliased_key(self):
     key = IntegerKey("aliased_name")
     keys = {"initial_name": key}
     definition = "{initial_name}"
     template = TemplatePath(definition, keys, self.project_root)
     input_path = os.path.join(self.project_root, "3")
     expected = {"aliased_name": 3}
     result = template.get_fields(input_path)
     self.assertEquals(expected, result)
開發者ID:benoit-leveau,項目名稱:tk-core,代碼行數:9,代碼來源:test_templatepath.py

示例7: test_key_first_short

 def test_key_first_short(self):
     definition =  "{Step}/{Shot}.png"
     template = TemplatePath(definition, self.keys, root_path=self.project_root)
     relative_path = os.path.join("Anm", "shot_1.png")
     file_path = os.path.join(self.project_root, relative_path)
     expected = {"Step": "Anm",
                 "Shot": "shot_1"}
     result = template.get_fields(file_path)
     self.assertEquals(result, expected)
開發者ID:benoit-leveau,項目名稱:tk-core,代碼行數:9,代碼來源:test_templatepath.py

示例8: test_double_int_key

 def test_double_int_key(self):
     """Test case that key of type int appears twice in definition."""
     int_key = IntegerKey("int_key")
     definition = "{int_key}/something/{int_key}.else"
     template = TemplatePath(definition, {"int_key": int_key}, root_path=self.project_root)
     expected = {"int_key": 4}
     relative_path = "4/something/4.else"
     input_path = os.path.join(self.project_root, relative_path)
     actual = template.get_fields(input_path)
     self.assertEquals(expected, actual)
開發者ID:benoit-leveau,項目名稱:tk-core,代碼行數:10,代碼來源:test_templatepath.py

示例9: test_key_at_end

 def test_key_at_end(self):
     definition = "sequences/{Sequence}/{Shot}/{Step}"
     template = TemplatePath(definition, self.keys, root_path=self.project_root)
     relative_path = "sequences/Seq1/Shot_1/Anm"
     input_path = os.path.join(self.project_root, relative_path)
     expected = {"Sequence": "Seq1",
                 "Shot": "Shot_1",
                 "Step": "Anm"}
     actual = template.get_fields(input_path)
     self.assertEquals(expected, actual)
開發者ID:benoit-leveau,項目名稱:tk-core,代碼行數:10,代碼來源:test_templatepath.py

示例10: test_diff_seperators

 def test_diff_seperators(self):
     definition = "shots/{Sequence}/{Shot}/{Step}/work"
     template = TemplatePath(definition, self.keys, root_path=self.project_root)
     relative_path = os.path.join("shots", "seq_1", "shot_1", "Anm", "work")
     file_path = os.path.join(self.project_root, relative_path)
     # adding extra seperator to end
     file_path = file_path + os.path.sep
     expected = {"Sequence": "seq_1",
                 "Shot": "shot_1",
                 "Step": "Anm"}
     result = template.get_fields(file_path)
     self.assertEquals(result, expected)
開發者ID:benoit-leveau,項目名稱:tk-core,代碼行數:12,代碼來源:test_templatepath.py

示例11: test_good_alphanumeric

    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,代碼行數:12,代碼來源:test_templatepath.py

示例12: test_format_default

    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,代碼行數:14,代碼來源:test_templatepath.py

示例13: test_optional_none_value

    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,代碼行數:15,代碼來源:test_templatepath.py

示例14: test_key_first

 def test_key_first(self):
     definition = "{Sequence}/{Shot}/{Step}/work/{Shot}.{branch}.v{version}.{snapshot}.ma"
     template = TemplatePath(definition, self.keys, root_path=self.project_root)
     relative_path = os.path.join("seq_1",
                                  "shot_1",
                                  "Anm",
                                  "work",
                                  "shot_1.mmm.v003.002.ma")
     file_path = os.path.join(self.project_root, relative_path)
     expected = {"Sequence": "seq_1",
                 "Shot": "shot_1",
                 "Step": "Anm",
                 "branch":"mmm",
                 "version": 3,
                 "snapshot": 2}
     result = template.get_fields(file_path)
     self.assertEquals(result, expected)
開發者ID:benoit-leveau,項目名稱:tk-core,代碼行數:17,代碼來源:test_templatepath.py

示例15: test_optional_values

    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,代碼行數:45,代碼來源:test_templatepath.py


注:本文中的tank.template.TemplatePath類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。