def run(self, text): def parse(x): return '<span class="line">{1}</span>{2}'.\ format(*parse_url(x.group())) def classify(x): return '{0} class="line"{1}'.format(*x.groups()) text = re_anchor.sub(classify, text) return re_url.sub(parse, text)
def sub(line): return re_url.sub(parse, line) return list(map(sub, lines))