def test_jump1(self): for name, res, num in [ [ "data0001.edf", "data99993.edf" , 99993 ], [ "bob1.edf", "bob0.edf", 0 ], [ "1.edf", "123456.edf" , 123456], [ "mydata001.mar2300.gz", "mydata003.mar2300.gz", 3 ], ]: self.assertEqual(res, fabio.jump_filename(name, num))
def test_jump1(self): for name, res, num in [ ["data0001.edf", "data99993.edf", 99993], ["bob1.edf", "bob0.edf", 0], ["1.edf", "123456.edf", 123456], ["mydata001.mar2300.gz", "mydata003.mar2300.gz", 3], ]: self.assertEqual(res, fabio.jump_filename(name, num))
def jump(self, newnum, noconvert=False): #FIXME - convert ??? newfilename = fabio.jump_filename(self.filename, newnum) try: self.__openimage(newfilename) #try to open that file except IOError: msg = "No such file: %s " % (newfilename) raise IOError(msg) #image loaded ok self.filename = newfilename self.number = newnum return True
def prev(self, steps=1): newnum = self.number - steps newfilename = fabio.jump_filename(self.filename, newnum) if newfilename == self.filename: raise ValueError("new filename == old filename") try: self.__openimage(newfilename) #try to open that file except IOError: newfilename = fabio.jump_filename(self.filename, newnum, padding=False) if newfilename == self.filename: raise ValueError("new filename == old filename") try: #that didn't work - so try the unpadded version self.openimage(newfilename) except IOError: msg = "No such file: %s " % (newfilename) raise IOError(msg) #image loaded ok self.filename = newfilename self.number = newnum return True
def next(self, steps=1): newnum = self.number + steps newfilename = fabio.jump_filename(self.filename, newnum) if newfilename == self.filename: raise ValueError("new filename == old filename") try: self.__openimage(newfilename) #try to open that file except IOError: msg = "No such file: %s " % (newfilename) raise IOError(msg) #image loaded ok self.filename = newfilename self.number = newnum return True
def test_more_cases_jump(self): for nname, oname, num in MORE_CASES: name = fabio.jump_filename(oname, num) self.assertEqual(name, nname)