From 50791b39057e00de66c38a1856e703f8182b4843 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Fri, 16 Dec 2005 07:34:03 +0000 Subject: [PATCH] optional resdir optional resdir --- python/aubio/bench/node.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/python/aubio/bench/node.py b/python/aubio/bench/node.py index efb3e005..bef1773f 100644 --- a/python/aubio/bench/node.py +++ b/python/aubio/bench/node.py @@ -41,23 +41,24 @@ def mkdir(path): cmd = '%s%s' % ('mkdir -p ',path) return runcommand(cmd) -def act_on_data (action,datapath,respath,suffix='.txt',filter='f',sub='\.wav$',**keywords): +def act_on_data (action,datapath,respath=None,suffix='.txt',filter='f',sub='\.wav$',**keywords): """ execute action(datafile,resfile) on all files in datapath """ dirlist = list_files(datapath,filter=filter) if dirlist == ['']: dirlist = [] - respath_in_datapath = re.split(datapath, respath,maxsplit=1)[1:] - if(respath_in_datapath and suffix == ''): - print 'error: respath in datapath and no suffix used' - #sys.exit(1) + if respath: + respath_in_datapath = re.split(datapath, respath,maxsplit=1)[1:] + if(respath_in_datapath and suffix == ''): + print 'error: respath in datapath and no suffix used' for i in dirlist: j = re.split(datapath, i,maxsplit=1)[1] j = re.sub(sub,'',j) #j = "%s%s%s"%(respath,j,suffix) - j = "%s%s"%(respath,j) - if sub != '': - j = re.sub(sub,suffix,j) - else: - j = "%s%s" % (j,suffix) + if respath: + j = "%s%s"%(respath,j) + if sub != '': + j = re.sub(sub,suffix,j) + else: + j = "%s%s" % (j,suffix) action(i,j,**keywords) def act_on_results (action,datapath,respath,filter='d'): @@ -72,9 +73,10 @@ def act_on_results (action,datapath,respath,filter='d'): class bench: - def __init__(self,datadir,resdir,checkres=False,checkanno=False): + def __init__(self,datadir,resdir=None,checkres=False,checkanno=False): self.datadir = datadir self.resdir = resdir + self.results = [] print "Checking data directory", self.datadir self.checkdata() if checkanno: self.checkanno() -- 2.26.2