def testMaxFrameSize(self): _maxSize = constants.MAX_FRAME_SIZE try: maxSize = constants.MAX_FRAME_SIZE = 500 # Within range utils.xfrange(1, 100, 1, maxSize=-1) utils.xfrange(1, 100, 1, maxSize=100) FrameSet('1-%d' % maxSize) # Should not be allowed self.assertRaises(exceptions.MaxSizeException, utils.xfrange, 1, 100, 1, maxSize=50) self.assertRaises(exceptions.MaxSizeException, FrameSet, '1-%d' % (maxSize + 1)) # Inverting would produce a huge new range fs = FrameSet('1,%d' % (maxSize + 3)) self.assertRaises(exceptions.MaxSizeException, fs.invertedFrameRange) finally: constants.MAX_FRAME_SIZE = _maxSize
def testIsConsecutive(self): consec = [ "10-100", "-100-100", "-100--50", "1,2,3,4,5", "5,6,7,8,9", "-5,-4,-3,-2,-1,0,1", "1,2,3,4,3,2,3,4,5,4", "-10-3,1-10,5-20,7-30", "10--10", "10-2,8-0,4--5", ] nonconsec = [ "10-20x2", "10-20x2,15-30x3", "-5-1,3-10", "-10-10x2", "10--1010x2", "1,2,3,4,6,7,8", "1,2,3,4,5,0", "5,4,3,2,1,6", ] for t in consec: self.assertTrue( FrameSet(t).isConsecutive(), "Expected %s to be consecutive" % t) for t in nonconsec: self.assertFalse( FrameSet(t).isConsecutive(), "Expected %s to not be consecutive" % t)
def parse_frame_list(frames): """frames: string of frames in usual form: 1 2 3 4-6 7-11:2 return: list of frames [1,2,3,4,5,6,7,9,11] """ from fileseq import FrameSet frames = frames.split() frames = ','.join(frames) fs = FrameSet(frames) return list(fs)
def testFloatFrameValues(self): table = [ ([1, 5.8, 10], [1, 5, 10]), ([1.5, 5, 10.2], [1, 5, 10]), ([1.001, 5, 10.999], [1, 5, 10]), ] for src, expected in table: f = FrameSet(src) actual = list(f) self.assertEqual(actual, expected)
def parse_frame_list(frames): """frames: string of frames in usual form: 1 2 3 4-6 7-11:2 return: list of frames [1,2,3,4,5,6,7,9,11] """ # Using external module https://github.com/sqlboy/fileseq from fileseq import FrameSet # Support colon and spaces: frames = frames.split() frames = ",".join(frames) fs = FrameSet(frames) return list(fs)
def test2FramesContiguous(self): table = [ ([1,2], "1-2"), ([-1,0], "-1-0"), ([-2,-1], "-2--1"), ([1,2,5,7,8,10,11], "1-2,5,7-8,10-11"), ([-5,-4,-1,1,2,5,7,8,12,13,14,15,16,52,53], "-5--4,-1,1-2,5,7-8,12-16,52-53"), ] for frames, expected in table: fs = FrameSet(frames) self.assertEqual(str(fs), expected)
def testSetFrameSet(self): seq = FileSequence("/cheech/chong.1-5#.exr") seq.setFrameSet(FrameSet("10-20")) self.assertEquals("/cheech/chong.10-20#.exr", str(seq))