summaryrefslogtreecommitdiffstats
path: root/Tools/scripts/parseentities.py
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/scripts/parseentities.py')
-rwxr-xr-xTools/scripts/parseentities.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/Tools/scripts/parseentities.py b/Tools/scripts/parseentities.py
index 4a44fb4..a042d1c 100755
--- a/Tools/scripts/parseentities.py
+++ b/Tools/scripts/parseentities.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
""" Utility for parsing HTML entity definitions available from:
http://www.w3.org/ as e.g.
@@ -13,7 +13,6 @@
"""
import re,sys
-import TextTools
entityRE = re.compile('<!ENTITY +(\w+) +CDATA +"([^"]+)" +-- +((?:.|\n)+?) *-->')
@@ -35,9 +34,8 @@ def parse(text,pos=0,endpos=None):
def writefile(f,defs):
f.write("entitydefs = {\n")
- items = defs.items()
- items.sort()
- for name,(charcode,comment) in items:
+ items = sorted(defs.items())
+ for name, (charcode,comment) in items:
if charcode[:2] == '&#':
code = int(charcode[2:-1])
if code < 256:
@@ -46,7 +44,7 @@ def writefile(f,defs):
charcode = repr(charcode)
else:
charcode = repr(charcode)
- comment = TextTools.collapse(comment)
+ comment = ' '.join(comment.split())
f.write(" '%s':\t%s, \t# %s\n" % (name,charcode,comment))
f.write('\n}\n')