def test_util(self): self.assertFalse(fs.Path.isSeparator(' ')) self.assertTrue(fs.Path.isSeparator('/')) self.assertTrue(fs.Path.isSeparator('\\')) for i in [fs.PathSeparator.Unix, fs.PathSeparator.Windows]: print(i, "=", fs.Path.getSeparator(i)) print("Current path separator =", fs.Path.getCurrentSeparator()) print("Absolute path =", fs.Path.getAbsolute(fs.Path(".")).get()) print("Current working directory =", fs.Path.getCWD().get()) print("Temp file path =", fs.Path.getTemp().get())
def test_Sequences(self): fi = fs.FileInfo(fs.Path("/tmp/file1-3.ext")) self.assertFalse(fi.isSequenceValid()) fi.evalSequence() self.assertTrue(fi.isSequenceValid()) self.assertEqual(fi.getSequence(), fr.Sequence(fr.Range(1, 3))) fi.setSequence(fr.Sequence(fr.Range(3, 1), 4)) fi.sortSequence() self.assertEqual(fi.getSequence(), fr.Sequence(fr.Range(1, 3), 4)) self.assertFalse(fi.isSequenceWildcard()) self.assertTrue(fs.FileInfo("/tmp/file#.ext").isSequenceWildcard()) self.assertTrue(fi.isCompatible(fs.FileInfo("/tmp/file2.ext"))) self.assertFalse(fi.isCompatible(fs.FileInfo("/tmp/render1.ext")))
def test_Members(self): self.assertEqual(fs.FileInfo("/").getPath(), fs.Path("/")) fi = fs.FileInfo() fi.setPath(fs.Path("/")) self.assertEqual(fi.getPath(), fs.Path("/")) fi.setPath(fs.Path("/"), fs.FileType.Directory) self.assertEqual(fi.getPath(), fs.Path("/")) self.assertEqual(fi.getType(), fs.FileType.Directory) fi.setPath(fs.Path("/tmp/file0001.ext")) self.assertEqual(fi.getFileName(), "/tmp/file0001.ext") fi.evalSequence() self.assertEqual(fi.getFileName(100), "/tmp/file0100.ext") self.assertEqual(fi.getFileName(100, False), "file0100.ext")
def test_components(self): path = fs.Path("/a/b1.ext") self.assertEqual(path.getFileName(), "b1.ext") self.assertEqual(path.getBaseName(), "b") self.assertEqual(path.getNumber(), "1") self.assertEqual(path.getExtension(), ".ext")
def test_cd(self): path = fs.Path("/a/b") path.cdUp() self.assertEqual(path.get(), fs.Path.getCurrentSeparator() + "a")
def test_root(self): self.assertFalse(fs.Path("").isRoot()) self.assertTrue(fs.Path("/").isRoot()) self.assertTrue(fs.Path("C:/").isRoot())
def test_members(self): path = fs.Path() path.set("/") self.assertEqual(path.get(), "/") path.append("a") self.assertEqual(path.get(), "/a")
def test_ctor(self): self.assertTrue(fs.Path().isEmpty()) self.assertEqual(fs.Path("/").get(), "/") self.assertEqual(fs.Path(fs.Path("/"), "a").get(), "/a") self.assertEqual(fs.Path("/", "a").get(), "/a")
def test_util(self): for f in fs.FileInfo.directoryList(fs.Path(".")): print(f.getFileName(fr.invalid, False))
def test_ctor(self): self.assertTrue(fs.FileInfo().isEmpty()) self.assertFalse(fs.FileInfo(fs.Path("/")).isEmpty()) self.assertFalse(fs.FileInfo(fs.Path("/"), fs.FileType.File).isEmpty()) self.assertFalse(fs.FileInfo("/").isEmpty())