<s> import argparse <EOL> import os <EOL> import tabulate <EOL> from fontTools import ttLib <EOL> from bakery_cli . fixers import RemoveNameRecordWithPlatformID_1_Fixer <EOL> args = argparse . ArgumentParser ( <EOL> description = '<STR_LIT>' ) <EOL> args . add_argument ( '<STR_LIT>' , nargs = "<STR_LIT:+>" ) <EOL> args . add_argument ( '<STR_LIT>' , default = False , action = '<STR_LIT:store_true>' , help = '<STR_LIT>' ) <EOL> args . add_argument ( '<STR_LIT>' , default = False , action = '<STR_LIT:store_true>' , help = '<STR_LIT>' ) <EOL> args . add_argument ( '<STR_LIT>' , '<STR_LIT>' , default = '<STR_LIT:all>' ) <EOL> args . add_argument ( '<STR_LIT>' , '<STR_LIT>' , type = int , default = <NUM_LIT:3> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> arg = args . parse_args ( ) <EOL> nameids = [ '<STR_LIT:1>' , '<STR_LIT:2>' , '<STR_LIT:4>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> user_nameids = [ x . strip ( ) for x in arg . id . split ( '<STR_LIT:U+002C>' ) ] <EOL> if '<STR_LIT:all>' not in user_nameids : <EOL> nameids = set ( nameids ) & set ( user_nameids ) <EOL> rows = [ ] <EOL> for font in arg . font : <EOL> ttfont = ttLib . TTFont ( font ) <EOL> row = [ os . path . basename ( font ) ] <EOL> for name in ttfont [ '<STR_LIT:name>' ] . names : <EOL> if str ( name . nameID ) not in nameids or name . platformID != arg . platform : <EOL> continue <EOL> value = name . string . decode ( name . getEncoding ( ) ) or '<STR_LIT>' <EOL> row . append ( value ) <EOL> rows . append ( row ) <EOL> header = [ '<STR_LIT:filename>' ] + [ '<STR_LIT:id>' + x for x in nameids ] <EOL> def as_csv ( rows ) : <EOL> import csv <EOL> import sys <EOL> writer = csv . writer ( sys . stdout ) <EOL> writer . writerows ( [ header ] ) <EOL> writer . writerows ( rows ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> if arg . csv : <EOL> as_csv ( rows ) <EOL> print ( tabulate . tabulate ( rows , header , tablefmt = "<STR_LIT>" ) ) <EOL> for path in arg . font : <EOL> if arg . autofix : <EOL> fixer = RemoveNameRecordWithPlatformID_1_Fixer ( None , path ) <EOL> fixer . apply ( ) </s>
