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")
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")
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)
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")
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())
def testMinute(self): """ Test that the minute procedure works properly. """ minute = TemplateProcedure.run("minute") self.assertGreaterEqual(int(minute), 0) self.assertLessEqual(int(minute), 59)
def testDay(self): """ Test that the day procedure works properly. """ dd = TemplateProcedure.run("dd") self.assertGreaterEqual(int(dd), 1) self.assertLessEqual(int(dd), 31)
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)
def testMonth(self): """ Test that the month procedure works properly. """ mm = TemplateProcedure.run("mm") self.assertGreaterEqual(int(mm), 1) self.assertLessEqual(int(mm), 12)
def testHour(self): """ Test that the hour procedure works properly. """ hour = TemplateProcedure.run("hour") self.assertGreaterEqual(int(hour), 0) self.assertLessEqual(int(hour), 23)
def testSecond(self): """ Test that the second procedure works properly. """ second = TemplateProcedure.run("second") self.assertGreaterEqual(int(second), 0) self.assertLessEqual(int(second), 59)
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)
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)
def testNewVersion(self): """ Test that the new procedure works properly. """ result = TemplateProcedure.run("newver", BaseTestCase.dataDirectory()) self.assertEqual(result, "v003")
def testDiv(self): """ Test that the div procedure works properly. """ result = TemplateProcedure.run("div", 6, 2) self.assertEqual(result, "3")
def testParentDirname(self): """ Test that the parentdirname procedure works properly. """ result = TemplateProcedure.run("parentdirname", self.__path) self.assertEqual(result, "/test")
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)
def testReplace(self): """ Test that the replace procedure works properly. """ result = TemplateProcedure.run("replace", "Boop", "o", "e") self.assertEqual(result, "Beep")
def testSum(self): """ Test that the sum procedure works properly. """ result = TemplateProcedure.run("sum", 1, 2) self.assertEqual(result, "3")
def testMax(self): """ Test that the max procedure works properly. """ result = TemplateProcedure.run("max", 6, 2) self.assertEqual(result, "6")
def testMin(self): """ Test that the min procedure works properly. """ result = TemplateProcedure.run("min", 6, 2) self.assertEqual(result, "2")
def testBasename(self): """ Test that the basename procedure works properly. """ result = TemplateProcedure.run("basename", self.__path) self.assertEqual(result, "example.ext")
def testRemove(self): """ Test that the remove procedure works properly. """ result = TemplateProcedure.run("remove", "boop", "p") self.assertEqual(result, "boo")
def testMult(self): """ Test that the mult procedure works properly. """ result = TemplateProcedure.run("mult", 2, 3) self.assertEqual(result, "6")
def testUpper(self): """ Test that the upper procedure works properly. """ result = TemplateProcedure.run("upper", "boop") self.assertEqual(result, "BOOP")
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)