def regexpreplace(cursor, regexp, s): text = replace_regex({}, cursor.line, regexp, s, matchcase=True) #Now uses whole line instead of just from the current char onwards #because Mp3tag is being a f*****g idiot. cursor.line = text cursor.charno = 0
def apply_regexps(audio, regexps=None): if regexps is None: regexps = DEFAULT_REGEXP audio = deepcopy(audio) changed = False for field, (regexp, output) in regexps.iteritems(): if field not in audio: continue text = to_string(audio[field]) try: val = replace_regex(audio, text, regexp, output) if val: audio[field] = val if not changed and val != text: changed = val except puddlestuff.findfunc.FuncError: continue return changed, audio