@@ -18,22 +18,25 @@ def getthreshop(thresh):
1818 return ['-thr %.10f -Tmin -bin' % (0.1 * val [1 ]) for val in thresh ]
1919
2020
21-
2221def pickrun (files , whichrun ):
2322 """pick file from list of files"""
2423
2524 filemap = {'first' : 0 , 'last' : - 1 , 'middle' : len (files ) // 2 }
2625
27- if isinstance (whichrun , str ):
28- if whichrun not in filemap .keys ():
29- raise (KeyError , 'Sorry, whichrun must be either integer index'
30- 'or string in form of "first", "last" or "middle' )
31- else :
32- return files [filemap [whichrun ]]
33-
3426 if isinstance (files , list ):
35- return files [whichrun ]
27+
28+ # whichrun is given as integer
29+ if isinstance (whichrun , int ):
30+ return files [whichrun ]
31+ # whichrun is given as string
32+ elif isinstance (whichrun , str ):
33+ if whichrun not in filemap .keys ():
34+ raise (KeyError , 'Sorry, whichrun must be either integer index'
35+ 'or string in form of "first", "last" or "middle' )
36+ else :
37+ return files [filemap [whichrun ]]
3638 else :
39+ # in case single file name is given
3740 return files
3841
3942
0 commit comments