def storeText(ffile): """ For each line of text in the list "lines", this function gets the corresponding box coordinates and saves the line as a doc in the "text" database. """ print "\nProcessing " + str(ffile) + "..." try: meifile = convert(str(ffile)) except Exception, e: lg.debug("Could not process file {0}. Threw exception: {1}".format(ffile, e))
def parseFile(self, filename): """docstring for parseFile""" self._meiDoc = convert(filename) self._create_registries() #self._parse_children(self._meiDoc.gettoplevel()) self._structure_work() for k,v in self._voice_registry.iteritems(): staff = k.split('.')[0] self._staff_registry[staff].append(v) self._score.append(self._staff_registry.values()) lg.debug(self._registry) lg.debug(self._contexts) lg.debug(self._staff_registry) self._score.show()
meifiles = [] for bd, dn, fn in os.walk(path): for f in fn: if not (('uncorr' in f) and os.path.exists(os.path.join(bd,f[0:5]+'corr.mei'))): # if current is uncorr version and corr version exists, don't add to list meifiles = meifiles + [os.path.join(bd,f)] meifiles.sort() couch = couchdb.Server("http://localhost:5984") textdb = couch['text'] # database for text # Iterate through each MEI file in directory from pymei.Import import convert for ffile in meifiles: print '\nProcessing ' + str(ffile) + '...' try: meifile = convert(str(ffile)) except Exception, e: lg.debug("Could not process file {0}. Threw exception: {1}".format(ffile, e)) page = meifile.search('page') pagen = int(page[0].attribute_by_name('n').value) notes = meifile.search('note') zones = meifile.search('zone') nnotes = len(notes) # number of notes in file #print str(nnotes) + 'notes\n' # get and store text if dotext: lines = meifile.search('l') #storeText(lines, zones, textdb) #Set these to control which databases you access