summaryrefslogtreecommitdiff
path: root/Tools/scripts/parseentities.py
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/scripts/parseentities.py')
-rwxr-xr-xTools/scripts/parseentities.py42
1 files changed, 21 insertions, 21 deletions
diff --git a/Tools/scripts/parseentities.py b/Tools/scripts/parseentities.py
index b708116f01..ab4f8300e9 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)