From d18915f920a0d9ab7ce5cfec4654d3d610b1d082 Mon Sep 17 00:00:00 2001 From: David Corbett Date: Sun, 28 Mar 2021 10:09:13 -0400 Subject: [PATCH] Reformat gen-tag-table.py --- src/gen-tag-table.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/gen-tag-table.py b/src/gen-tag-table.py index 62d79c7ff..d1b5d4342 100755 --- a/src/gen-tag-table.py +++ b/src/gen-tag-table.py @@ -25,10 +25,8 @@ Input files: """ import collections +import html from html.parser import HTMLParser -def write (s): - sys.stdout.flush () - sys.stdout.buffer.write (s.encode ('utf-8')) import itertools import re import sys @@ -37,16 +35,16 @@ import unicodedata if len (sys.argv) != 3: sys.exit (__doc__) -from html import unescape -def html_unescape (parser, entity): - return unescape (entity) - def expect (condition, message=None): if not condition: if message is None: raise AssertionError raise AssertionError (message) +def write (s): + sys.stdout.flush () + sys.stdout.buffer.write (s.encode ('utf-8')) + DEFAULT_LANGUAGE_SYSTEM = '' # from https://www-01.sil.org/iso639-3/iso-639-3.tab @@ -383,10 +381,10 @@ class OpenTypeRegistryParser (HTMLParser): self._current_tr[-1] += data 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): - self.handle_data (html_unescape (self, '&%s;' % name)) + self.handle_data (html.unescape ('&%s;' % name)) def parse (self, filename): """Parse the OpenType language system tag registry.