Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def testFindSequencesOnDiskSkipHiddenFiles(self):
seqs = findSequencesOnDisk("seqhidden")
self.assertEquals(3, len(seqs))
known = set(self.toNormpaths([
"seqhidden/bar1000-1002,1004-1006#.exr",
"seqhidden/foo.1-5#.exr",
"seqhidden/foo.1-5#.jpg",
]))
found = set(self.toNormpaths([str(s) for s in seqs]))
self.assertEqual(known, found)
self.assertFalse(known.difference(found))
def testFormat(self):
seq = FileSequence("/cheech/chong.1-10,30,40#.exr")
self.assertEquals("chong.0001-0010,0030,0040#.exr", str(seq.format()))
self.assertNativeStr(seq.format())
self.assertEquals("0011-0029,0031-0039", seq.format("{inverted}"))
self.assertNativeStr(seq.format("{inverted}"))
seq = findSequencesOnDisk("broken_seq")[0]
self.assertEquals("0000-0002,0004,0006-0008", seq.format("{range}"))
self.assertEquals("broke.0000-0002,0004,0006-0008#.exr", seq.format())
seq = findSequencesOnDisk("step_seq")[0]
self.assertEquals("step_seq/step1.1-13x4,14-17#.exr", str(seq))
("seq/foo.debug.#.exr", ["seq/foo.debug.1-5#.exr"]),
("seq/#.exr", ["seq/1-3#.exr"]),
("seq/foo_#.exr", ["seq/foo_1#.exr"]),
("seq/foo_#_extra.exr", []),
("seq/foo_##.exr", []),
("seq/foo_@.exr", []),
("seq/foo_#@.exr", []),
("seq/foo_@@_extra.exr", []),
("seq/baz_{left,right}.#.exr", ["seq/baz_left.1-3#.exr", "seq/baz_right.1-3#.exr"]),
("seq/baz_{left,right}.@@@@.exr", ["seq/baz_left.1-3@@@@.exr", "seq/baz_right.1-3@@@@.exr"]),
("seq/baz_{left,right}.@@@.exr", []),
("seq/baz_{left,right}.#@.exr", []),
]
for pattern, expected in tests:
seqs = findSequencesOnDisk(pattern, strictPadding=True)
for seq in seqs:
self.assertTrue(isinstance(seq, FileSequence))
actual = self.toNormpaths([str(seq) for seq in seqs])
expected = self.toNormpaths(expected)
self.assertEqual(actual, expected)
def testNegSequencesOnDisk(self):
seqs = findSequencesOnDisk("seqneg")
self.assertEquals(1, len(seqs))
def testFindSequencesOnDiskIncludeHiddenFiles(self):
seqs = findSequencesOnDisk("seqhidden", include_hidden=True)
self.assertEquals(7, len(seqs))
known = {
"seqhidden/bar1000-1002,1004-1006#.exr",
"seqhidden/.bar1000-1002,1004-1006#.exr",
"seqhidden/foo.1-5#.exr",
"seqhidden/.foo.1-5#.exr",
"seqhidden/foo.1-5#.jpg",
"seqhidden/.foo.1-5#.jpg",
"seqhidden/.hidden",
}
found = set([str(s) for s in seqs])
self.assertEqualPaths(known, found)
def testFindSequenceOnDiskNegative(self):
seqs = findSequencesOnDisk("seqneg")
self.assertEquals("seqneg/bar.-1-1#.exr", str(seqs[0]))
self.assertEquals("seqneg/bar.-001.exr", seqs[0].frame(-1))
self.assertEquals("seqneg/bar.-1001.exr", seqs[0].frame(-1001))
self.assertEquals("seqneg/bar.-10011.exr", seqs[0].frame(-10011))
self.assertEquals("seqneg/bar.1000.exr", seqs[0].frame(1000))
def testFindSequencesOnDisk(self):
seqs = findSequencesOnDisk("seq", strictPadding=True)
self.assertEquals(len(seqs), 10)
known = {
"seq/bar1000-1002,1004-1006#.exr",
"seq/foo.1-5#.exr",
"seq/foo.1-5#.jpg",
"seq/foo.debug.1-5#.exr",
"seq/foo_1#.exr",
"seq/foo_0001_extra.exr",
"seq/1-3#.exr",
"seq/baz_left.1-3#.exr",
"seq/baz_right.1-3#.exr",
"seq/big.999-1003#.ext",
}
found = set([str(s) for s in seqs])
self.assertEqualPaths(found, known)
def testFormat(self):
seq = FileSequence("/cheech/chong.1-10,30,40#.exr")
self.assertEquals("chong.0001-0010,0030,0040#.exr", str(seq.format()))
self.assertNativeStr(seq.format())
self.assertEquals("0011-0029,0031-0039", seq.format("{inverted}"))
self.assertNativeStr(seq.format("{inverted}"))
seq = findSequencesOnDisk("broken_seq")[0]
self.assertEquals("0000-0002,0004,0006-0008", seq.format("{range}"))
self.assertEquals("broke.0000-0002,0004,0006-0008#.exr", seq.format())
seq = findSequencesOnDisk("step_seq")[0]
self.assertEquals("step_seq/step1.1-13x4,14-17#.exr", str(seq))
expected = {
"seqsubdirs/sub1/1-3#.exr",
"seqsubdirs/sub1/bar1000-1002,1004-1006#.exr",
"seqsubdirs/sub1/foo.1-5#.exr",
"seqsubdirs/sub1/foo.1-5#.jpg",
"seqsubdirs/sub1/foo.debug.1-5#.exr",
"seqsubdirs/sub1/foo_1#.exr",
}
import ntpath
_join = os.path.join
os.path.join = ntpath.join
try:
self.assertEqual(os.path.join('a', 'b'), 'a\\b')
seqs = findSequencesOnDisk("seqsubdirs/sub1")
self.assertEquals(len(expected), len(seqs))
actual = set(str(s) for s in seqs)
self.assertEqual(actual, expected)
finally:
os.path.join = _join