History

clarify list functions, add task class clarify list functions, add task class

Paul Brossier committed 20 years ago

Commit 257debc1 parent 74730741 file · +45 −6Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/aubio/bench/node.py+45−6
@@ -15,17 +15,24 @@ def runcommand(cmd,debug=0): · 14 unmodified lines
1515 print 'error:',status,output
1616 print 'command returning error was',cmd
1717 #sys.exit(1)
18+ if output == '' or output == ['']: return
1819 return output
1920
20−def list_files(datapath,filter='f'):
21− cmd = '%s%s%s%s' % ('find ',datapath,' -type ',filter)
21+def list_files(datapath,filter='f', maxdepth = -1):
22+ if maxdepth >= 0: maxstring = " -maxdepth %d " % maxdepth
23+ else: maxstring = ""
24+ cmd = '%s' * 5 % ('find ',datapath,maxstring,' -type ',filter)
2225 return runcommand(cmd)
2326
24−def list_wav_files(datapath,maxdepth=1):
25− return list_files(datapath, filter="f -name '*.wav' -maxdepth %d"%maxdepth)
27+def list_wav_files(datapath,maxdepth = -1):
28+ return list_files(datapath, filter="f -name '*.wav'",maxdepth = maxdepth)
2629
27−def list_snd_files(datapath,maxdepth=1):
28− return list_files(datapath, filter="f -name '*.wav' -o -name '*.aif' -maxdepth %d"%maxdepth)
30+def list_snd_files(datapath,maxdepth = -1):
31+ return list_files(datapath, filter="f -name '*.wav' -o -name '*.aif'",
32+ maxdepth = maxdepth)
33+
34+def list_res_files(datapath,maxdepth = -1):
35+ return list_files(datapath, filter="f -name '*.txt'", maxdepth = maxdepth)
2936
3037 def list_dirs(datapath):
3138 return list_files(datapath, filter="d")
@@ -62,3 +69,35 @@ def act_on_results (action,datapath,respath,filter='d'): · 30 unmodified lines
6269 for i in dirlist:
6370 s = re.split(datapath, i ,maxsplit=1)[1]
6471 action("%s%s%s"%(respath,'/',s))
72+
73+class task:
74+
75+ def __init__(self,datadir,resdir):
76+ self.datadir = datadir
77+ self.resdir = resdir
78+ print "Checking data directory", self.datadir
79+ self.checkdata()
80+ self.checkres()
81+
82+ def checkdata(self):
83+ print "Listing directories in data directory",
84+ self.dirlist = list_dirs(self.datadir)
85+ print " (%d elements)" % len(self.dirlist)
86+ #for each in self.dirlist: print each
87+ print "Listing sound files in data directory",
88+ self.sndlist = list_snd_files(self.datadir)
89+ print " (%d elements)" % len(self.sndlist)
90+ #for each in self.sndlist: print each
91+ print "Listing annotations in data directory",
92+ self.reslist = list_res_files(self.datadir)
93+ print " (%d elements)" % len(self.reslist)
94+ #for each in self.reslist: print each
95+ if not self.reslist or len(self.reslist) < len (self.sndlist):
96+ print "ERR: not enough annotations"
97+ return -1
98+ else:
99+ print "Found enough annotations"
100+
101+ def checkres(self):
102+ print "Creating results directory"
103+ act_on_results(mkdir,self.datadir,self.resdir,filter='d')

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t