Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def check_filterlist_equals_namelist(filterlist, namelistFilename, namelistCache=None):
codepoints, noncodes = read_filterlist(filterlist)
namelist = fonts.ReadNameList(namelistFilename, cache=namelistCache)
message = []
codepoints_set = set(c for c, _ in codepoints)
if codepoints_set != namelist['ownCharset']:
formatCodePoints = '0x{0:04X}'.format
codepoints_not_in_namelist = codepoints_set - namelist['ownCharset']
if len(codepoints_not_in_namelist):
message.append('Unicode in filter list missing in Namelist:\n{0}'\
.format(', '.join(formatCodePoints(c) for c
in sorted(codepoints_not_in_namelist))))
codepoints_not_in_filterlist = namelist['ownCharset'] - codepoints_set
if len(codepoints_not_in_filterlist):
message.append('Unicode in Namelist missing in filter list:\n{0}'\
.format(', '.join(formatCodePoints(c) for c
in sorted(codepoints_not_in_filterlist))))
noncodes_set = set(noncodes)
def check_filterlist_in_namelist(filterListFileName, namelistCache=None):
namelistFilename = get_namelist_for_filterlist(filterListFileName)
if not namelistFilename:
return False, 'No Namelist file found for {filterlist}'.format(filterlist=filterListFileName), None
codepoints, noncodes = read_filterlist(filterListFileName)
useProductionNames = 'uni names' in filterListFileName or 'uni-names' in filterListFileName
if useProductionNames:
prod_noncodes = noncodes;
noncodes = [translate_name(name) for name in noncodes]
noncodes2prodcodes = dict(zip(noncodes, prod_noncodes))
namelist = fonts.ReadNameList(namelistFilename, cache=namelistCache)
message = []
missingChars = []
for codepoint in codepoints:
if codepoint[0] not in namelist['charset']:
missingChars.append(codepoint)
if len(missingChars):
names = ', '.join(['0x{0:04X} {1}'.format(c, name)
for c, name in missingChars])
message.append('Unicode chars not in Namelist but in filter list:' \
'\n[{names}]'.format(names=names))
missingNoncodes = []
namelistNoCharcode = set(translate_name(name) for name in namelist['noCharcode'])
for noncode in noncodes: