Reformat gen-tag-table.py

This commit is contained in:
David Corbett 2021-03-28 10:09:13 -04:00 committed by Behdad Esfahbod
parent 3c8273ab68
commit d18915f920
1 changed files with 7 additions and 9 deletions

View File

@ -25,10 +25,8 @@ Input files:
""" """
import collections import collections
import html
from html.parser import HTMLParser from html.parser import HTMLParser
def write (s):
sys.stdout.flush ()
sys.stdout.buffer.write (s.encode ('utf-8'))
import itertools import itertools
import re import re
import sys import sys
@ -37,16 +35,16 @@ import unicodedata
if len (sys.argv) != 3: if len (sys.argv) != 3:
sys.exit (__doc__) sys.exit (__doc__)
from html import unescape
def html_unescape (parser, entity):
return unescape (entity)
def expect (condition, message=None): def expect (condition, message=None):
if not condition: if not condition:
if message is None: if message is None:
raise AssertionError raise AssertionError
raise AssertionError (message) raise AssertionError (message)
def write (s):
sys.stdout.flush ()
sys.stdout.buffer.write (s.encode ('utf-8'))
DEFAULT_LANGUAGE_SYSTEM = '' DEFAULT_LANGUAGE_SYSTEM = ''
# from https://www-01.sil.org/iso639-3/iso-639-3.tab # from https://www-01.sil.org/iso639-3/iso-639-3.tab
@ -383,10 +381,10 @@ class OpenTypeRegistryParser (HTMLParser):
self._current_tr[-1] += data self._current_tr[-1] += data
def handle_charref (self, name): def handle_charref (self, name):
self.handle_data (html_unescape (self, '&#%s;' % name)) self.handle_data (html.unescape ('&#%s;' % name))
def handle_entityref (self, name): def handle_entityref (self, name):
self.handle_data (html_unescape (self, '&%s;' % name)) self.handle_data (html.unescape ('&%s;' % name))
def parse (self, filename): def parse (self, filename):
"""Parse the OpenType language system tag registry. """Parse the OpenType language system tag registry.