minor, use py3's open(encoding=)
This commit is contained in:
parent
cd5580e2d6
commit
ad87155fd0
|
@ -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."])
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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]
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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."])
|
||||
|
|
|
@ -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 ()
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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 ():
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue