some style improvements to check-copyright-notices script
-#!/usr/bin/env python3
+#!/usr/bin/env python
import argparse
import os
import tabulate
from fontTools import ttLib
+from fontbakery.constants import (NAMEID_COPYRIGHT_NOTICE,
+ PLATID_STR)
parser = argparse.ArgumentParser(description='Print out copyright'
' nameIDs strings')
@@ -14,30 +16,31 @@ parser.add_argument('--csv', default=False, action='store_true',
def main():
args = parser.parse_args()
- nameids = '0'
rows = []
for font in args.font:
ttfont = ttLib.TTFont(font)
- row = [os.path.basename(font)]
for name in ttfont['name'].names:
- if str(name.nameID) not in nameids:
+ if name.nameID != NAMEID_COPYRIGHT_NOTICE:
continue
value = name.string.decode(name.getEncoding()) or ''
- row.append(value)
- row.append(len(value))
+ rows.append([os.path.basename(font),
+ value,
+ len(value),
+ "{} ({})".format(
+ name.platformID,
+ PLATID_STR.get(name.platformID, "?"))])
- rows.append(row)
-
- header = ['filename', 'copyright notice', 'char length']
+ header = ['filename', 'copyright notice', 'char length', 'platformID']
def as_csv(rows):
import csv
import sys
writer = csv.writer(sys.stdout,
delimiter='|',
- quotechar='"', quoting=csv.QUOTE_MINIMAL)
+ quotechar='"',
+ quoting=csv.QUOTE_MINIMAL)
writer.writerows([header])
writer.writerows(rows)
sys.exit(0)
@@ -45,14 +48,13 @@ def main():
if args.csv:
as_csv(rows)
+ print("") #some spacing
print(tabulate.tabulate(rows, header, tablefmt="pipe"))
+ print("") #some spacing
if __name__ == '__main__':
- """
-
- Example usage:
+ """ Example usage:
fontbakery-check-copyright-notices.py ~/fonts/*/*/*ttf --csv > ~/notices.txt;
-
"""
main()
