mirror of
https://github.com/googlefonts/noto-emoji.git
synced 2025-06-08 15:57:59 +00:00
Merge pull request #129 from dougfelt/emoji_name_limit
Let user control error limit parameter in generate_emoji_name_data.
This commit is contained in:
commit
aedda3111b
1 changed files with 7 additions and 5 deletions
|
@ -273,7 +273,7 @@ def _name_data(seq, seq_file):
|
||||||
|
|
||||||
|
|
||||||
def generate_names(
|
def generate_names(
|
||||||
src_dir, dst_dir, pretty_print=False, verbose=False):
|
src_dir, dst_dir, skip_limit=20, pretty_print=False, verbose=False):
|
||||||
srcdir = tool_utils.resolve_path(src_dir)
|
srcdir = tool_utils.resolve_path(src_dir)
|
||||||
if not path.isdir(srcdir):
|
if not path.isdir(srcdir):
|
||||||
print >> sys.stderr, '%s is not a directory' % src_dir
|
print >> sys.stderr, '%s is not a directory' % src_dir
|
||||||
|
@ -322,7 +322,6 @@ def generate_names(
|
||||||
data = []
|
data = []
|
||||||
last_skipped_group = None
|
last_skipped_group = None
|
||||||
skipcount = 0
|
skipcount = 0
|
||||||
skip_limit = 20
|
|
||||||
for group in unicode_data.get_emoji_groups():
|
for group in unicode_data.get_emoji_groups():
|
||||||
name_data = []
|
name_data = []
|
||||||
for seq in unicode_data.get_emoji_in_group(group):
|
for seq in unicode_data.get_emoji_in_group(group):
|
||||||
|
@ -338,7 +337,7 @@ def generate_names(
|
||||||
print ' %s (%s)' % (
|
print ' %s (%s)' % (
|
||||||
unicode_data.seq_to_string(seq),
|
unicode_data.seq_to_string(seq),
|
||||||
', '.join(unicode_data.name(cp, 'x') for cp in seq))
|
', '.join(unicode_data.name(cp, 'x') for cp in seq))
|
||||||
if skipcount > skip_limit:
|
if skip_limit >= 0 and skipcount > skip_limit:
|
||||||
raise Exception('skipped too many items')
|
raise Exception('skipped too many items')
|
||||||
else:
|
else:
|
||||||
name_data.append(_name_data(seq, seq_file))
|
name_data.append(_name_data(seq, seq_file))
|
||||||
|
@ -366,13 +365,16 @@ def main():
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-p', '--pretty_print', help='pretty-print json file',
|
'-p', '--pretty_print', help='pretty-print json file',
|
||||||
action='store_true')
|
action='store_true')
|
||||||
|
parser.add_argument(
|
||||||
|
'-m', '--missing_limit', help='number of missing images before failure '
|
||||||
|
'(default 20), use -1 for no limit', metavar='n', default=20)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-v', '--verbose', help='print progress information to stdout',
|
'-v', '--verbose', help='print progress information to stdout',
|
||||||
action='store_true')
|
action='store_true')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
generate_names(
|
generate_names(
|
||||||
args.srcdir, args.dstdir, pretty_print=args.pretty_print,
|
args.srcdir, args.dstdir, args.missing_limit,
|
||||||
verbose=args.verbose)
|
pretty_print=args.pretty_print, verbose=args.verbose)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Reference in a new issue