Ignore:
Timestamp:
Dec 16, 2005, 2:22:58 AM (19 years ago)
Author:
Paul Brossier <piem@altern.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
75139a9
Parents:
7473074
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/aubio/bench/node.py

    r7473074 r257debc  
    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)
     21def 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)
     27def 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)
     30def list_snd_files(datapath,maxdepth = -1):
     31        return list_files(datapath, filter="f -name '*.wav' -o -name '*.aif'",
     32                maxdepth = maxdepth)
     33
     34def list_res_files(datapath,maxdepth = -1):
     35        return list_files(datapath, filter="f -name '*.txt'", maxdepth = maxdepth)
    2936
    3037def list_dirs(datapath):
     
    6370                s = re.split(datapath, i ,maxsplit=1)[1]
    6471                action("%s%s%s"%(respath,'/',s))
     72
     73class 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')
Note: See TracChangeset for help on using the changeset viewer.