diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-09-18 01:46:01 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-09-18 01:46:01 (GMT) |
commit | 0b7b4b8a229532bb7f634aedf0db81adfeb2ae18 (patch) | |
tree | f45a6aec7140a61df9c85730e95c5fd0a94356dd /Tools/scripts/parseentities.py | |
parent | 9082cdd009cc5c4945cd1200cc58f6bf69eb2817 (diff) | |
download | cpython-0b7b4b8a229532bb7f634aedf0db81adfeb2ae18.zip cpython-0b7b4b8a229532bb7f634aedf0db81adfeb2ae18.tar.gz cpython-0b7b4b8a229532bb7f634aedf0db81adfeb2ae18.tar.bz2 |
satisfy the tabnanny
Diffstat (limited to 'Tools/scripts/parseentities.py')
-rwxr-xr-x | Tools/scripts/parseentities.py | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/Tools/scripts/parseentities.py b/Tools/scripts/parseentities.py index b708116..ab4f830 100755 --- a/Tools/scripts/parseentities.py +++ b/Tools/scripts/parseentities.py @@ -21,15 +21,15 @@ def parse(text,pos=0,endpos=None): pos = 0 if endpos is None: - endpos = len(text) + endpos = len(text) d = {} while 1: - m = entityRE.search(text,pos,endpos) - if not m: - break - name,charcode,comment = m.groups() - d[name] = charcode,comment - pos = m.end() + m = entityRE.search(text,pos,endpos) + if not m: + break + name,charcode,comment = m.groups() + d[name] = charcode,comment + pos = m.end() return d def writefile(f,defs): @@ -38,27 +38,27 @@ def writefile(f,defs): items = defs.items() items.sort() for name,(charcode,comment) in items: - if charcode[:2] == '&#': - code = int(charcode[2:-1]) - if code < 256: - charcode = "'\%o'" % code - else: - charcode = repr(charcode) - else: - charcode = repr(charcode) - comment = TextTools.collapse(comment) - f.write(" '%s':\t%s, \t# %s\n" % (name,charcode,comment)) + if charcode[:2] == '&#': + code = int(charcode[2:-1]) + if code < 256: + charcode = "'\%o'" % code + else: + charcode = repr(charcode) + else: + charcode = repr(charcode) + comment = TextTools.collapse(comment) + f.write(" '%s':\t%s, \t# %s\n" % (name,charcode,comment)) f.write('\n}\n') if __name__ == '__main__': if len(sys.argv) > 1: - infile = open(sys.argv[1]) + infile = open(sys.argv[1]) else: - infile = sys.stdin + infile = sys.stdin if len(sys.argv) > 2: - outfile = open(sys.argv[2],'w') + outfile = open(sys.argv[2],'w') else: - outfile = sys.stdout + outfile = sys.stdout text = infile.read() defs = parse(text) writefile(outfile,defs) |