Project

General

Profile

« Previous | Next » 

Revision 9785

bin/repl: added unescape_html() filter function, which can be specified as the replacement string

View differences:

bin/repl
3 3
# A->C or B->C
4 4

  
5 5
import csv
6
import HTMLParser
6 7
import os.path
7 8
import re
8 9
import sys
......
13 14
import opts
14 15
import strings
15 16

  
17
def unescape_html(str_): return HTMLParser.HTMLParser().unescape(str_)
18

  
19
def repl_unescape_html(match): return unescape_html(match.group(0))
20

  
16 21
def main():
17 22
    env_names = []
18 23
    def usage_err():
......
43 48
    stream.close()
44 49
    def repl_all(str_):
45 50
        str_ = strings.ustr(str_)
46
        for repl, with_ in repls: str_ = re.sub(repl, with_, str_)
51
        for repl, with_ in repls:
52
            if with_ == 'unescape_html()': with_ = repl_unescape_html
53
            str_ = re.sub(repl, with_, str_)
47 54
        return str_
48 55
    
49 56
    # Modify map or file

Also available in: Unified diff