diff --git a/src/gen-arabic-table.py b/src/gen-arabic-table.py index e4a4ddf46..50501ce7f 100755 --- a/src/gen-arabic-table.py +++ b/src/gen-arabic-table.py @@ -8,12 +8,12 @@ Input files: * https://unicode.org/Public/UCD/latest/ucd/Blocks.txt """ -import io, os.path, sys +import os.path, sys if len (sys.argv) != 4: sys.exit (__doc__) -files = [io.open (x, encoding='utf-8') for x in sys.argv[1:]] +files = [open (x, encoding='utf-8') for x in sys.argv[1:]] headers = [[files[0].readline (), files[0].readline ()], [files[2].readline (), files[2].readline ()]] headers.append (["UnicodeData.txt does not have a header."]) diff --git a/src/gen-def.py b/src/gen-def.py index 21e49c4f1..b6b8b20c5 100755 --- a/src/gen-def.py +++ b/src/gen-def.py @@ -2,7 +2,7 @@ "usage: gen-def.py harfbuzz.def hb.h [hb-blob.h hb-buffer.h ...]" -import io, os, re, sys +import os, re, sys if len (sys.argv) < 3: sys.exit(__doc__) @@ -13,7 +13,7 @@ header_paths = sys.argv[2:] headers_content = [] for h in header_paths: if h.endswith (".h"): - with io.open (h, encoding='utf-8') as f: headers_content.append (f.read ()) + with open (h, encoding='utf-8') as f: headers_content.append (f.read ()) symbols = sorted (re.findall (r"^hb_\w+(?= \()", "\n".join (headers_content), re.M)) if '--experimental-api' not in sys.argv: diff --git a/src/gen-indic-table.py b/src/gen-indic-table.py index c45e99b8c..1746aab67 100755 --- a/src/gen-indic-table.py +++ b/src/gen-indic-table.py @@ -8,7 +8,7 @@ Input files: * https://unicode.org/Public/UCD/latest/ucd/Blocks.txt """ -import io, sys +import sys if len (sys.argv) != 4: sys.exit (__doc__) @@ -37,7 +37,7 @@ ALLOWED_BLOCKS = [ 'Myanmar Extended-A', ] -files = [io.open (x, encoding='utf-8') for x in sys.argv[1:]] +files = [open (x, encoding='utf-8') for x in sys.argv[1:]] headers = [[f.readline () for i in range (2)] for f in files] diff --git a/src/gen-os2-unicode-ranges.py b/src/gen-os2-unicode-ranges.py index a17219d56..6faebefc3 100755 --- a/src/gen-os2-unicode-ranges.py +++ b/src/gen-os2-unicode-ranges.py @@ -16,7 +16,7 @@ print ("""static OS2Range _hb_os2_unicode_ranges[] = args = sys.argv[1:] input_file = args[0] -with io.open(input_file, mode="r", encoding="utf-8") as f: +with open (input_file, mode="r", encoding="utf-8") as f: all_ranges = [] current_bit = 0 diff --git a/src/gen-tag-table.py b/src/gen-tag-table.py index e78389c11..401f4ca5b 100755 --- a/src/gen-tag-table.py +++ b/src/gen-tag-table.py @@ -29,7 +29,6 @@ from html.parser import HTMLParser def write (s): sys.stdout.flush () sys.stdout.buffer.write (s.encode ('utf-8')) -import io import itertools import re import sys @@ -393,7 +392,7 @@ class OpenTypeRegistryParser (HTMLParser): Args: filename (str): The file name of the registry. """ - with io.open (filename, encoding='utf-8') as f: + with open (filename, encoding='utf-8') as f: self.feed (f.read ()) expect (self.header) for tag, iso_codes in self.to_bcp_47.items (): @@ -535,7 +534,7 @@ class BCP47Parser (object): Args: filename (str): The file name of the registry. """ - with io.open (filename, encoding='utf-8') as f: + with open (filename, encoding='utf-8') as f: subtag_type = None subtag = None deprecated = False diff --git a/src/gen-use-table.py b/src/gen-use-table.py index 4845c1981..19ad26376 100755 --- a/src/gen-use-table.py +++ b/src/gen-use-table.py @@ -10,7 +10,6 @@ Input file: * https://unicode.org/Public/UCD/latest/ucd/Blocks.txt """ -import io import sys if len (sys.argv) != 5: @@ -18,7 +17,7 @@ if len (sys.argv) != 5: BLACKLISTED_BLOCKS = ["Thai", "Lao"] -files = [io.open (x, encoding='utf-8') for x in sys.argv[1:]] +files = [open (x, encoding='utf-8') for x in sys.argv[1:]] headers = [[f.readline () for i in range (2)] for j,f in enumerate(files) if j != 2] headers.append (["UnicodeData.txt does not have a header."]) diff --git a/src/gen-vowel-constraints.py b/src/gen-vowel-constraints.py index 4e17173f9..7f23dc8e6 100755 --- a/src/gen-vowel-constraints.py +++ b/src/gen-vowel-constraints.py @@ -19,13 +19,12 @@ def write (s): sys.stdout.flush () sys.stdout.buffer.write (s.encode ('utf-8')) import itertools -import io import sys if len (sys.argv) != 3: sys.exit (__doc__) -with io.open (sys.argv[2], encoding='utf-8') as f: +with open (sys.argv[2], encoding='utf-8') as f: scripts_header = [f.readline () for i in range (2)] scripts = {} script_order = {} @@ -128,7 +127,7 @@ class ConstraintSet (object): return ''.join (s) constraints = {} -with io.open (sys.argv[1], encoding='utf-8') as f: +with open (sys.argv[1], encoding='utf-8') as f: constraints_header = [] while True: line = f.readline ().strip () diff --git a/test/subset/generate-expected-outputs.py b/test/subset/generate-expected-outputs.py index 286de8d4c..2e94e4e78 100755 --- a/test/subset/generate-expected-outputs.py +++ b/test/subset/generate-expected-outputs.py @@ -3,7 +3,6 @@ # Pre-generates the expected output subset files (via fonttools) for # specified subset test suite(s). -import io import os import sys @@ -32,7 +31,7 @@ if not args: usage() for path in args: - with io.open(path, mode="r", encoding="utf-8") as f: + with open(path, mode="r", encoding="utf-8") as f: test_suite = SubsetTestSuite(path, f.read()) output_directory = test_suite.get_output_directory() diff --git a/test/subset/run-tests.py b/test/subset/run-tests.py index 2948084ed..10b775113 100755 --- a/test/subset/run-tests.py +++ b/test/subset/run-tests.py @@ -3,7 +3,6 @@ # Runs a subsetting test suite. Compares the results of subsetting via harfbuzz # to subsetting via fonttools. -import io from difflib import unified_diff import os import re @@ -74,9 +73,9 @@ def run_test (test, should_check_ots): if os.path.exists (actual_ttx): os.remove (actual_ttx) return fail_test (test, cli_args, "ttx (actual) returned %d" % (return_code)) - with io.open (expected_ttx, encoding='utf-8') as f: + with open (expected_ttx, encoding='utf-8') as f: expected_ttx_text = f.read () - with io.open (actual_ttx, encoding='utf-8') as f: + with open (actual_ttx, encoding='utf-8') as f: actual_ttx_text = f.read () # cleanup @@ -137,7 +136,7 @@ has_ots = has_ots() fails = 0 for path in args: - with io.open (path, mode="r", encoding="utf-8") as f: + with open (path, mode="r", encoding="utf-8") as f: print ("Running tests in " + path) test_suite = SubsetTestSuite (path, f.read ()) for test in test_suite.tests (): diff --git a/test/subset/subset_test_suite.py b/test/subset/subset_test_suite.py index a990fa0b3..d549fd669 100644 --- a/test/subset/subset_test_suite.py +++ b/test/subset/subset_test_suite.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -import io import os # A single test in a subset test suite. Identifies a font @@ -18,7 +17,7 @@ class Test: return ",".join("%X" % ord(c) for (i, c) in enumerate(self.subset)) def get_profile_flags(self): - with io.open(self.profile_path, mode="r", encoding="utf-8") as f: + with open(self.profile_path, mode="r", encoding="utf-8") as f: return f.read().splitlines(); def get_font_name(self):