@@ -18,22 +18,25 @@ def getthreshop(thresh):
18
18
return ['-thr %.10f -Tmin -bin' % (0.1 * val [1 ]) for val in thresh ]
19
19
20
20
21
-
22
21
def pickrun (files , whichrun ):
23
22
"""pick file from list of files"""
24
23
25
24
filemap = {'first' : 0 , 'last' : - 1 , 'middle' : len (files ) // 2 }
26
25
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
-
34
26
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 ]]
36
38
else :
39
+ # in case single file name is given
37
40
return files
38
41
39
42
0 commit comments