formatting with black to get lint to pass
This commit is contained in:
parent
45d1d01f66
commit
9656e3faf1
@ -161,7 +161,7 @@ def test(glyphsets, glyphs=None, names=None, ignore_missing=False):
|
|||||||
for glyphset, name in zip(glyphsets, names):
|
for glyphset, name in zip(glyphsets, names):
|
||||||
|
|
||||||
glyph = glyphset[glyph_name]
|
glyph = glyphset[glyph_name]
|
||||||
|
|
||||||
if glyph is None:
|
if glyph is None:
|
||||||
if not ignore_missing:
|
if not ignore_missing:
|
||||||
add_problem(glyph_name, {"type": "missing", "master": name})
|
add_problem(glyph_name, {"type": "missing", "master": name})
|
||||||
@ -248,12 +248,14 @@ def test(glyphsets, glyphs=None, names=None, ignore_missing=False):
|
|||||||
_rot_list([complex(*pt) for pt, bl in mirrored], i)
|
_rot_list([complex(*pt) for pt, bl in mirrored], i)
|
||||||
)
|
)
|
||||||
|
|
||||||
# m0idx should be the index of the first non-None item in allNodeTypes,
|
# m0idx should be the index of the first non-None item in allNodeTypes,
|
||||||
# else give it the first index of None, which is likely 0
|
# else give it the first index of None, which is likely 0
|
||||||
m0idx = allNodeTypes.index(next((x for x in allNodeTypes if x is not None), None))
|
m0idx = allNodeTypes.index(
|
||||||
|
next((x for x in allNodeTypes if x is not None), None)
|
||||||
|
)
|
||||||
# m0 is the first non-None item in allNodeTypes, or the first item if all are None
|
# m0 is the first non-None item in allNodeTypes, or the first item if all are None
|
||||||
m0 = allNodeTypes[m0idx]
|
m0 = allNodeTypes[m0idx]
|
||||||
for i, m1 in enumerate(allNodeTypes[m0idx+1:]):
|
for i, m1 in enumerate(allNodeTypes[m0idx + 1 :]):
|
||||||
if m1 is None:
|
if m1 is None:
|
||||||
continue
|
continue
|
||||||
if len(m0) != len(m1):
|
if len(m0) != len(m1):
|
||||||
@ -301,12 +303,14 @@ def test(glyphsets, glyphs=None, names=None, ignore_missing=False):
|
|||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# m0idx should be the index of the first non-None item in allVectors,
|
# m0idx should be the index of the first non-None item in allVectors,
|
||||||
# else give it the first index of None, which is likely 0
|
# else give it the first index of None, which is likely 0
|
||||||
m0idx = allVectors.index(next((x for x in allVectors if x is not None), None))
|
m0idx = allVectors.index(
|
||||||
|
next((x for x in allVectors if x is not None), None)
|
||||||
|
)
|
||||||
# m0 is the first non-None item in allVectors, or the first item if all are None
|
# m0 is the first non-None item in allVectors, or the first item if all are None
|
||||||
m0 = allVectors[m0idx]
|
m0 = allVectors[m0idx]
|
||||||
for i, m1 in enumerate(allVectors[m0idx+1:]):
|
for i, m1 in enumerate(allVectors[m0idx + 1 :]):
|
||||||
if m1 is None:
|
if m1 is None:
|
||||||
continue
|
continue
|
||||||
if len(m0) != len(m1):
|
if len(m0) != len(m1):
|
||||||
@ -333,13 +337,15 @@ def test(glyphsets, glyphs=None, names=None, ignore_missing=False):
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
|
||||||
# m0idx should be the index of the first non-None item in allContourIsomorphisms,
|
# m0idx should be the index of the first non-None item in allContourIsomorphisms,
|
||||||
# else give it the first index of None, which is likely 0
|
# else give it the first index of None, which is likely 0
|
||||||
m0idx = allContourIsomorphisms.index(next((x for x in allContourIsomorphisms if x is not None), None))
|
m0idx = allContourIsomorphisms.index(
|
||||||
|
next((x for x in allContourIsomorphisms if x is not None), None)
|
||||||
|
)
|
||||||
# m0 is the first non-None item in allContourIsomorphisms, or the first item if all are None
|
# m0 is the first non-None item in allContourIsomorphisms, or the first item if all are None
|
||||||
m0 = allContourIsomorphisms[m0idx]
|
m0 = allContourIsomorphisms[m0idx]
|
||||||
for i, m1 in enumerate(allContourIsomorphisms[m0idx+1:]):
|
for i, m1 in enumerate(allContourIsomorphisms[m0idx + 1 :]):
|
||||||
if m1 is None:
|
if m1 is None:
|
||||||
continue
|
continue
|
||||||
if len(m0) != len(m1):
|
if len(m0) != len(m1):
|
||||||
@ -397,7 +403,11 @@ def main(args=None):
|
|||||||
help="Will not report glyphs missing from sparse masters as errors",
|
help="Will not report glyphs missing from sparse masters as errors",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"inputs", metavar="FILE", type=str, nargs="+", help="Input a single DesignSpace/Glyphs file, or multiple TTF/UFO files"
|
"inputs",
|
||||||
|
metavar="FILE",
|
||||||
|
type=str,
|
||||||
|
nargs="+",
|
||||||
|
help="Input a single DesignSpace/Glyphs file, or multiple TTF/UFO files",
|
||||||
)
|
)
|
||||||
|
|
||||||
args = parser.parse_args(args)
|
args = parser.parse_args(args)
|
||||||
@ -477,11 +487,11 @@ def main(args=None):
|
|||||||
glyphset = font.getGlyphSet()
|
glyphset = font.getGlyphSet()
|
||||||
else:
|
else:
|
||||||
glyphset = font
|
glyphset = font
|
||||||
glyphsets.append({k:glyphset[k] for k in glyphset.keys()})
|
glyphsets.append({k: glyphset[k] for k in glyphset.keys()})
|
||||||
|
|
||||||
if not glyphs:
|
if not glyphs:
|
||||||
glyphs = set([gn for glyphset in glyphsets for gn in glyphset.keys()])
|
glyphs = set([gn for glyphset in glyphsets for gn in glyphset.keys()])
|
||||||
|
|
||||||
for glyphset in glyphsets:
|
for glyphset in glyphsets:
|
||||||
glyphSetGlyphNames = set(glyphset.keys())
|
glyphSetGlyphNames = set(glyphset.keys())
|
||||||
diff = glyphs - glyphSetGlyphNames
|
diff = glyphs - glyphSetGlyphNames
|
||||||
@ -489,8 +499,10 @@ def main(args=None):
|
|||||||
for gn in diff:
|
for gn in diff:
|
||||||
glyphset[gn] = None
|
glyphset[gn] = None
|
||||||
|
|
||||||
problems = test(glyphsets, glyphs=glyphs, names=names, ignore_missing=args.ignore_missing)
|
problems = test(
|
||||||
|
glyphsets, glyphs=glyphs, names=names, ignore_missing=args.ignore_missing
|
||||||
|
)
|
||||||
|
|
||||||
if not args.quiet:
|
if not args.quiet:
|
||||||
if args.json:
|
if args.json:
|
||||||
import json
|
import json
|
||||||
|
@ -105,7 +105,7 @@ class InterpolatableTest(unittest.TestCase):
|
|||||||
def test_glyphsapp(self):
|
def test_glyphsapp(self):
|
||||||
glyphsapp_path = self.get_test_input("InterpolateLayout.glyphs")
|
glyphsapp_path = self.get_test_input("InterpolateLayout.glyphs")
|
||||||
self.assertIsNone(interpolatable_main([glyphsapp_path]))
|
self.assertIsNone(interpolatable_main([glyphsapp_path]))
|
||||||
|
|
||||||
def test_VF(self):
|
def test_VF(self):
|
||||||
suffix = ".ttf"
|
suffix = ".ttf"
|
||||||
ttx_dir = self.get_test_input("master_ttx_varfont_ttf")
|
ttx_dir = self.get_test_input("master_ttx_varfont_ttf")
|
||||||
@ -116,10 +116,10 @@ class InterpolatableTest(unittest.TestCase):
|
|||||||
self.compile_font(path, suffix, self.tempdir)
|
self.compile_font(path, suffix, self.tempdir)
|
||||||
|
|
||||||
ttf_paths = self.get_file_list(self.tempdir, suffix)
|
ttf_paths = self.get_file_list(self.tempdir, suffix)
|
||||||
|
|
||||||
problems = interpolatable_main(["--quiet"] + ttf_paths)
|
problems = interpolatable_main(["--quiet"] + ttf_paths)
|
||||||
self.assertIsNone(problems)
|
self.assertIsNone(problems)
|
||||||
|
|
||||||
def test_sparse_interpolatable_ttfs(self):
|
def test_sparse_interpolatable_ttfs(self):
|
||||||
suffix = ".ttf"
|
suffix = ".ttf"
|
||||||
ttx_dir = self.get_test_input("master_ttx_interpolatable_ttf")
|
ttx_dir = self.get_test_input("master_ttx_interpolatable_ttf")
|
||||||
@ -130,64 +130,127 @@ class InterpolatableTest(unittest.TestCase):
|
|||||||
self.compile_font(path, suffix, self.tempdir)
|
self.compile_font(path, suffix, self.tempdir)
|
||||||
|
|
||||||
ttf_paths = self.get_file_list(self.tempdir, suffix)
|
ttf_paths = self.get_file_list(self.tempdir, suffix)
|
||||||
|
|
||||||
# without --ignore-missing
|
# without --ignore-missing
|
||||||
problems = interpolatable_main(["--quiet"] + ttf_paths)
|
problems = interpolatable_main(["--quiet"] + ttf_paths)
|
||||||
self.assertEqual(problems['a'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}])
|
self.assertEqual(
|
||||||
self.assertEqual(problems['s'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}])
|
problems["a"],
|
||||||
self.assertEqual(problems['edotabove'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}])
|
[{"type": "missing", "master": "SparseMasters-Medium"}]
|
||||||
self.assertEqual(problems['dotabovecomb'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}])
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
problems["s"],
|
||||||
|
[{"type": "missing", "master": "SparseMasters-Medium"}]
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
problems["edotabove"],
|
||||||
|
[{"type": "missing", "master": "SparseMasters-Medium"}],
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
problems["dotabovecomb"],
|
||||||
|
[{"type": "missing", "master": "SparseMasters-Medium"}],
|
||||||
|
)
|
||||||
|
|
||||||
# normal order, with --ignore-missing
|
# normal order, with --ignore-missing
|
||||||
self.assertIsNone(interpolatable_main(["--ignore-missing"] + ttf_paths))
|
self.assertIsNone(interpolatable_main(["--ignore-missing"] + ttf_paths))
|
||||||
# purposely putting the sparse master (medium) first
|
# purposely putting the sparse master (medium) first
|
||||||
self.assertIsNone(interpolatable_main(["--ignore-missing"] + [ttf_paths[1]] + [ttf_paths[0]] + [ttf_paths[2]]))
|
self.assertIsNone(
|
||||||
|
interpolatable_main(
|
||||||
|
["--ignore-missing"] + [ttf_paths[1]] + [ttf_paths[0]] + [ttf_paths[2]]
|
||||||
|
)
|
||||||
|
)
|
||||||
# purposely putting the sparse master (medium) last
|
# purposely putting the sparse master (medium) last
|
||||||
self.assertIsNone(interpolatable_main(["--ignore-missing"] + [ttf_paths[0]] + [ttf_paths[2]] + [ttf_paths[1]]))
|
self.assertIsNone(
|
||||||
|
interpolatable_main(
|
||||||
|
["--ignore-missing"] + [ttf_paths[0]] + [ttf_paths[2]] + [ttf_paths[1]]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def test_sparse_interpolatable_ufos(self):
|
def test_sparse_interpolatable_ufos(self):
|
||||||
ttx_dir = self.get_test_input("master_ufo")
|
ttx_dir = self.get_test_input("master_ufo")
|
||||||
ufo_paths = self.get_file_list(ttx_dir, ".ufo", "SparseMasters-")
|
ufo_paths = self.get_file_list(ttx_dir, ".ufo", "SparseMasters-")
|
||||||
|
|
||||||
# without --ignore-missing
|
# without --ignore-missing
|
||||||
problems = interpolatable_main(["--quiet"] + ufo_paths)
|
problems = interpolatable_main(["--quiet"] + ufo_paths)
|
||||||
self.assertEqual(problems['a'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}])
|
self.assertEqual(
|
||||||
self.assertEqual(problems['s'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}])
|
problems["a"],
|
||||||
self.assertEqual(problems['edotabove'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}])
|
[{"type": "missing", "master": "SparseMasters-Medium"}]
|
||||||
self.assertEqual(problems['dotabovecomb'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}])
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
problems["s"],
|
||||||
|
[{"type": "missing", "master": "SparseMasters-Medium"}]
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
problems["edotabove"],
|
||||||
|
[{"type": "missing", "master": "SparseMasters-Medium"}],
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
problems["dotabovecomb"],
|
||||||
|
[{"type": "missing", "master": "SparseMasters-Medium"}],
|
||||||
|
)
|
||||||
|
|
||||||
# normal order, with --ignore-missing
|
# normal order, with --ignore-missing
|
||||||
self.assertIsNone(interpolatable_main(["--ignore-missing"] + ufo_paths))
|
self.assertIsNone(interpolatable_main(["--ignore-missing"] + ufo_paths))
|
||||||
# purposely putting the sparse master (medium) first
|
# purposely putting the sparse master (medium) first
|
||||||
self.assertIsNone(interpolatable_main(["--ignore-missing"] + [ufo_paths[1]] + [ufo_paths[0]] + [ufo_paths[2]]))
|
self.assertIsNone(
|
||||||
|
interpolatable_main(
|
||||||
|
["--ignore-missing"] + [ufo_paths[1]] + [ufo_paths[0]] + [ufo_paths[2]]
|
||||||
|
)
|
||||||
|
)
|
||||||
# purposely putting the sparse master (medium) last
|
# purposely putting the sparse master (medium) last
|
||||||
self.assertIsNone(interpolatable_main(["--ignore-missing"] + [ufo_paths[0]] + [ufo_paths[2]] + [ufo_paths[1]]))
|
self.assertIsNone(
|
||||||
|
interpolatable_main(
|
||||||
|
["--ignore-missing"] + [ufo_paths[0]] + [ufo_paths[2]] + [ufo_paths[1]]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def test_sparse_designspace(self):
|
def test_sparse_designspace(self):
|
||||||
designspace_path = self.get_test_input("SparseMasters_ufo.designspace")
|
designspace_path = self.get_test_input("SparseMasters_ufo.designspace")
|
||||||
|
|
||||||
problems = interpolatable_main(["--quiet", designspace_path])
|
problems = interpolatable_main(["--quiet", designspace_path])
|
||||||
self.assertEqual(problems['a'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}])
|
self.assertEqual(
|
||||||
self.assertEqual(problems['s'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}])
|
problems["a"],
|
||||||
self.assertEqual(problems['edotabove'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}])
|
[{"type": "missing", "master": "SparseMasters-Medium"}]
|
||||||
self.assertEqual(problems['dotabovecomb'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}])
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
problems["s"],
|
||||||
|
[{"type": "missing", "master": "SparseMasters-Medium"}]
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
problems["edotabove"],
|
||||||
|
[{"type": "missing", "master": "SparseMasters-Medium"}],
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
problems["dotabovecomb"],
|
||||||
|
[{"type": "missing", "master": "SparseMasters-Medium"}],
|
||||||
|
)
|
||||||
|
|
||||||
# normal order, with --ignore-missing
|
# normal order, with --ignore-missing
|
||||||
self.assertIsNone(interpolatable_main(["--ignore-missing", designspace_path]))
|
self.assertIsNone(interpolatable_main(["--ignore-missing", designspace_path]))
|
||||||
|
|
||||||
def test_sparse_designspace(self):
|
def test_sparse_designspace(self):
|
||||||
glyphsapp_path = self.get_test_input("SparseMasters.glyphs")
|
glyphsapp_path = self.get_test_input("SparseMasters.glyphs")
|
||||||
|
|
||||||
problems = interpolatable_main(["--quiet", glyphsapp_path])
|
problems = interpolatable_main(["--quiet", glyphsapp_path])
|
||||||
self.assertEqual(problems['a'], [{'type': 'missing', 'master': 'Sparse Masters-Medium'}])
|
self.assertEqual(
|
||||||
self.assertEqual(problems['s'], [{'type': 'missing', 'master': 'Sparse Masters-Medium'}])
|
problems["a"],
|
||||||
self.assertEqual(problems['edotabove'], [{'type': 'missing', 'master': 'Sparse Masters-Medium'}])
|
[{"type": "missing", "master": "Sparse Masters-Medium"}]
|
||||||
self.assertEqual(problems['dotabovecomb'], [{'type': 'missing', 'master': 'Sparse Masters-Medium'}])
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
problems["s"],
|
||||||
|
[{"type": "missing", "master": "Sparse Masters-Medium"}]
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
problems["edotabove"],
|
||||||
|
[{"type": "missing", "master": "Sparse Masters-Medium"}],
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
problems["dotabovecomb"],
|
||||||
|
[{"type": "missing", "master": "Sparse Masters-Medium"}],
|
||||||
|
)
|
||||||
|
|
||||||
# normal order, with --ignore-missing
|
# normal order, with --ignore-missing
|
||||||
self.assertIsNone(interpolatable_main(["--ignore-missing", glyphsapp_path]))
|
self.assertIsNone(interpolatable_main(["--ignore-missing", glyphsapp_path]))
|
||||||
|
|
||||||
|
|
||||||
def test_interpolatable_varComposite(self):
|
def test_interpolatable_varComposite(self):
|
||||||
input_path = self.get_test_input(
|
input_path = self.get_test_input(
|
||||||
"..", "..", "ttLib", "data", "varc-ac00-ac01.ttf"
|
"..", "..", "ttLib", "data", "varc-ac00-ac01.ttf"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user