Esempio n. 1
0
 def testPadding(self):
     """
     Test that the padding procedure works properly.
     """
     padding = TemplateProcedure.run("pad", 1, 4)
     self.assertEqual(padding, "0001")
     padding = TemplateProcedure.run("pad", 100, 6)
     self.assertEqual(padding, "000100")
Esempio n. 2
0
 def testRetimePadding(self):
     """
     Test that the retime padding procedure works properly.
     """
     padding = TemplateProcedure.run("retimepad", 1, 5, 4)
     self.assertEqual(padding, "0006")
     padding = TemplateProcedure.run("retimepad", 100, -99, 6)
     self.assertEqual(padding, "000001")
Esempio n. 3
0
 def testYear(self):
     """
     Test that the year template procedures work properly.
     """
     yyyy = TemplateProcedure.run("yyyy")
     self.assertGreaterEqual(int(yyyy), 2018)
     yy = TemplateProcedure.run("yy")
     self.assertEqual(yyyy[-2:], yy)
Esempio n. 4
0
 def testLatestVersion(self):
     """
     Test that the latest version is found properly.
     """
     result = TemplateProcedure.run("latestver",
                                    BaseTestCase.dataDirectory())
     self.assertEqual(result, "v002")
     result = TemplateProcedure.run(
         "latestver", os.path.join(BaseTestCase.dataDirectory(), "glob"))
     self.assertEqual(result, "v000")
Esempio n. 5
0
    def testRegistration(self):
        """
        Test that the procedure registration works properly.
        """
        def myDummyTemplateProcedure(a, b):
            return '{}-{}'.format(a, b)

        self.assertRaises(TemplateProcedureNotFoundError,
                          TemplateProcedure.run, "dummy")
        TemplateProcedure.register("dummy", myDummyTemplateProcedure)
        self.assertIn("dummy", TemplateProcedure.registeredNames())
Esempio n. 6
0
 def testMinute(self):
     """
     Test that the minute procedure works properly.
     """
     minute = TemplateProcedure.run("minute")
     self.assertGreaterEqual(int(minute), 0)
     self.assertLessEqual(int(minute), 59)
Esempio n. 7
0
 def testDay(self):
     """
     Test that the day procedure works properly.
     """
     dd = TemplateProcedure.run("dd")
     self.assertGreaterEqual(int(dd), 1)
     self.assertLessEqual(int(dd), 31)
Esempio n. 8
0
 def testParseRun(self):
     """
     Test that running a procedure through string parsing works.
     """
     result = TemplateProcedure.parseRun("dirname {}".format(self.__path))
     self.assertEqual(result, "/test/path")
     self.assertRaises(AssertionError, TemplateProcedure.parseRun, True)
Esempio n. 9
0
 def testMonth(self):
     """
     Test that the month procedure works properly.
     """
     mm = TemplateProcedure.run("mm")
     self.assertGreaterEqual(int(mm), 1)
     self.assertLessEqual(int(mm), 12)
Esempio n. 10
0
 def testHour(self):
     """
     Test that the hour procedure works properly.
     """
     hour = TemplateProcedure.run("hour")
     self.assertGreaterEqual(int(hour), 0)
     self.assertLessEqual(int(hour), 23)
Esempio n. 11
0
 def testSecond(self):
     """
     Test that the second procedure works properly.
     """
     second = TemplateProcedure.run("second")
     self.assertGreaterEqual(int(second), 0)
     self.assertLessEqual(int(second), 59)
Esempio n. 12
0
 def testRFindPath(self):
     """
     Test that the rfind procedure works properly.
     """
     result = TemplateProcedure.run('rfindpath', 'test.txt',
                                    self.__testRFindPath)
     testPath = os.path.join(BaseTestCase.dataDirectory(), 'test.txt')
     self.assertEqual(result, testPath)
Esempio n. 13
0
 def testFindPath(self):
     """
     Test that the find procedure works properly.
     """
     result = TemplateProcedure.run("findpath", 'TestCrawler.py',
                                    BaseTestCase.dataDirectory())
     testPath = os.path.join(BaseTestCase.dataDirectory(), 'config',
                             'crawlers', 'TestCrawler.py')
     self.assertEqual(result, testPath)
Esempio n. 14
0
 def testNewVersion(self):
     """
     Test that the new procedure works properly.
     """
     result = TemplateProcedure.run("newver", BaseTestCase.dataDirectory())
     self.assertEqual(result, "v003")
Esempio n. 15
0
 def testDiv(self):
     """
     Test that the div procedure works properly.
     """
     result = TemplateProcedure.run("div", 6, 2)
     self.assertEqual(result, "3")
Esempio n. 16
0
 def testParentDirname(self):
     """
     Test that the parentdirname procedure works properly.
     """
     result = TemplateProcedure.run("parentdirname", self.__path)
     self.assertEqual(result, "/test")
Esempio n. 17
0
        return "Final"
    # Sent for review
    elif sg_status_list == "sfr":
        return "Work in Progress"
    else:
        return "Work in Progress"


def fileTypeTemplateProcedure(filePath):
    """
    Return a nice name for the file type.
    """
    name, ext = os.path.splitext(filePath)
    if ext == ".mov":
        if name.endswith("_h264"):
            return "H264"
        elif name.endswith("_prores"):
            return "PRORES"
        else:
            return "DNxHD"
    elif ext == ".exr":
        return "EXR"
    else:
        return ext.upper().strip(".")


# registering template procedures
TemplateProcedure.register('clientStatus', clientStatusTemplateProcedure)

TemplateProcedure.register('clientFileType', fileTypeTemplateProcedure)
Esempio n. 18
0
 def testReplace(self):
     """
     Test that the replace procedure works properly.
     """
     result = TemplateProcedure.run("replace", "Boop", "o", "e")
     self.assertEqual(result, "Beep")
Esempio n. 19
0
 def testSum(self):
     """
     Test that the sum procedure works properly.
     """
     result = TemplateProcedure.run("sum", 1, 2)
     self.assertEqual(result, "3")
Esempio n. 20
0
 def testMax(self):
     """
     Test that the max procedure works properly.
     """
     result = TemplateProcedure.run("max", 6, 2)
     self.assertEqual(result, "6")
Esempio n. 21
0
 def testMin(self):
     """
     Test that the min procedure works properly.
     """
     result = TemplateProcedure.run("min", 6, 2)
     self.assertEqual(result, "2")
Esempio n. 22
0
 def testBasename(self):
     """
     Test that the basename procedure works properly.
     """
     result = TemplateProcedure.run("basename", self.__path)
     self.assertEqual(result, "example.ext")
Esempio n. 23
0
 def testRemove(self):
     """
     Test that the remove procedure works properly.
     """
     result = TemplateProcedure.run("remove", "boop", "p")
     self.assertEqual(result, "boo")
Esempio n. 24
0
 def testMult(self):
     """
     Test that the mult procedure works properly.
     """
     result = TemplateProcedure.run("mult", 2, 3)
     self.assertEqual(result, "6")
Esempio n. 25
0
 def testUpper(self):
     """
     Test that the upper procedure works properly.
     """
     result = TemplateProcedure.run("upper", "boop")
     self.assertEqual(result, "BOOP")
Esempio n. 26
0
import os
import re
from centipede.TemplateProcedure import TemplateProcedure


def plateNewVersionTemplateProcedure(prefix, job, seq, shot, plateName):
    """
    Returns a new version for the plate.
    """
    plateLocation = "{prefix}/{job}/sequences/{seq}/{shot}/online/publish/elements/{plateName}".format(
        prefix=prefix, job=job, seq=seq, shot=shot, plateName=plateName)

    version = 0
    versionRegEx = "^v[0-9]{3}$"

    # finding the latest version
    if os.path.exists(plateLocation):
        for directory in os.listdir(plateLocation):
            if re.match(versionRegEx, directory):
                version = max(int(directory[1:]), version)

    return 'v' + str(version + 1).zfill(3)


# registering procedure
TemplateProcedure.register('plateNewVersion', plateNewVersionTemplateProcedure)