def aff(abc): aabc = cleanupHeaders(removeNonAscii(abc)) l = [] for line in aabc.split('\n'): logger.info(line) l.append(line) logger.info(l)
def newAbcTune(context, event): try: context.abc = removeNonAscii(context.abc) addQ(context) addTuneType(context) addOrigins(context) addKeys(context) _make_midi(context) _make_score(context) # _make_mp3(context) logger.info("abc created !") except: logger.info("abctune not created...")
def processABC(self, data): # tunes = data.split('\n') data = removeNonAscii(data) rawtunes = data.split('X:') for rawtune in rawtunes: tune = rawtune.split('\n')[1:] tune.insert(0, 'X:1') newtune = ('\n').join(self.cleanup(tune)) tuneId = self.getTuneId(tune) tuneTitle = self.getTuneTitle(tune) tuneSubject = self.getSubject(tune) if tuneId != 'collective.abcmusic.NoId': self.createTune(newtune=newtune, tuneId=tuneId, tuneTitle=tuneTitle, tuneSubject=tuneSubject)
def updateAbcTune(context, event): try: context.abc = removeNonAscii(context.abc) addQ(context) addTuneType(context) addOrigins(context) addKeys(context) _make_midi(context) _make_score(context) parent = context.aq_parent if parent.portal_type == 'abctuneset': log = '(IObjectModifiedEvent)abctune.updateAbcTune ' log += parent.portal_type logger.info(log) notify(TuneInTuneSetModified(context)) # _make_mp3(context) except: logger.info("updateAbcTune : abctune not modified...")
def reorgenize(abcText, part): abcText = cleanupHeaders(removeNonAscii(abcText)) usefulHeaders = ['P:', 'Q:', 'M:', 'L:', 'K:', 'C:', 'T:'] comments = [] newABCTextLines = [] Q = M = L = K = T = Parts = '' for line in abcText.split('\n'): if line[:1] == '%': comments.append(line.strip('\r')) # logger.info(line) # import pdb;pdb.set_trace() if line[:2] == 'T:': T = line + '\n' if line[:2] == 'Q:': Q = line + '\n' if line[:2] == 'M:': M = line + '\n' if line[:2] == 'L:': L = line + '\n' if line[:2] == 'K:': K = line + '\n' if line[:2] == 'P:': if Parts == '': Parts = line.split(':')[1].strip() if (line[:1] != '%' and line[:2] not in usefulHeaders): newABCTextLines.append(line) headers = '\n'.join(comments) headers += '\n' + T + M + L + K headers += 'P:' + part + '\n' + Q newABCText = headers newABCText += '\n'.join(newABCTextLines) # if there is no P: header, we play only one time this tune if Parts == '': Parts = part else: Parts = part * len(Parts) # logger.info(newABCText) # logger.info('---------') # import pdb;pdb.set_trace() return newABCText, Parts
def getFirstTitle(abcText): # because T: is mandatory, no more verifications tabc = abcText.split('T:') title = tabc[1].split('\n')[0].strip() return removeNonAscii(title)