Skip to content

Commit

Permalink
Small tweaks in coverage.py
Browse files Browse the repository at this point in the history
  • Loading branch information
cpitclaudel committed Apr 25, 2019
1 parent dfd9638 commit 7b77dff
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def parse_arguments():
class FontInfo(object):
def __init__(self, path, glyphs):
"""Check for unicode GLYPHS in font at PATH"""
font = fontforge.open(os.path.abspath(path))
font = fontforge.open(os.path.abspath(path).decode("utf-8"))
self.path = path
self.glyphs = glyphs
self.fontname = font.fontname
Expand Down Expand Up @@ -75,23 +75,28 @@ def collect_font_info(glyphs, fnt):
return None

def imap_helper(glyphs_fnt):
try:
return collect_font_info(*glyphs_fnt)
except Exception as e:
print("ERROR:", e)
return None
# try:
return collect_font_info(*glyphs_fnt)
# except Exception as e:
# print("ERROR:", e)
# return None

PARALLEL = False

def collect_fonts_info(glyphs, fonts):
pool = multiprocessing.Pool()
for idx, info in enumerate(pool.imap_unordered(imap_helper, izip(repeat(glyphs), fonts))):
if PARALLEL:
pool = multiprocessing.Pool()
infos = pool.imap_unordered(imap_helper, izip(repeat(glyphs), fonts))
else:
infos = (imap_helper((glyphs, fnt)) for fnt in fonts)
for idx, info in enumerate(infos):
print(">>> {} <<<".format(idx))
if info:
yield info

def main():
args = parse_arguments()
args.glyphs = [g.decode("utf-8") for g in args.glyphs]

infos = list(collect_fonts_info(args.glyphs, args.fonts))
infos.sort(key=lambda info: len(info.supported))

Expand Down

0 comments on commit 7b77dff

Please sign in to comment.