mirror of
https://github.com/googlefonts/noto-emoji.git
synced 2025-06-08 15:57:59 +00:00
Add limit option to generate_emoji_html.
By default the tool uses all sequences that appear in any of the image sets. To make it easier to see just the changes between a smaller set of images and a large one, this lets you limit the sequences to just those in the first set being compared.
This commit is contained in:
parent
8b2596d76a
commit
5fd46ab136
1 changed files with 16 additions and 8 deletions
|
@ -102,10 +102,12 @@ def _get_name(key_tuple):
|
||||||
return CELL_PREFIX + name
|
return CELL_PREFIX + name
|
||||||
|
|
||||||
|
|
||||||
def _generate_content(basedir, dir_infos):
|
def _generate_content(basedir, dir_infos, limit):
|
||||||
"""Generate an html table for the infos. basedir is the parent directory
|
"""Generate an html table for the infos. basedir is the parent directory
|
||||||
of the content, filenames will be made relative to this if underneath it,
|
of the content, filenames will be made relative to this if underneath it,
|
||||||
else absolute."""
|
else absolute. If limit is true and there are multiple dirs, limit the set of
|
||||||
|
sequences to those in the first dir."""
|
||||||
|
|
||||||
lines = ['<table>']
|
lines = ['<table>']
|
||||||
header_row = ['']
|
header_row = ['']
|
||||||
header_row.extend([info.title for info in dir_infos])
|
header_row.extend([info.title for info in dir_infos])
|
||||||
|
@ -122,7 +124,10 @@ def _generate_content(basedir, dir_infos):
|
||||||
dirspec = abs_filedir
|
dirspec = abs_filedir
|
||||||
basepaths.append(dirspec)
|
basepaths.append(dirspec)
|
||||||
|
|
||||||
all_keys = _merge_keys([info.filemap for info in dir_infos])
|
if len(dir_infos) == 1 or limit:
|
||||||
|
all_keys = frozenset(dir_infos[0].filemap.keys())
|
||||||
|
else:
|
||||||
|
all_keys = _merge_keys([info.filemap for info in dir_infos])
|
||||||
for key in sorted(all_keys):
|
for key in sorted(all_keys):
|
||||||
row = []
|
row = []
|
||||||
row.extend(_generate_row_cells(key, dir_infos, basepaths))
|
row.extend(_generate_row_cells(key, dir_infos, basepaths))
|
||||||
|
@ -254,8 +259,8 @@ STYLE = """
|
||||||
td.name { background-color: white }
|
td.name { background-color: white }
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def write_html_page(filename, page_title, dir_infos):
|
def write_html_page(filename, page_title, dir_infos, limit):
|
||||||
content = _generate_content(path.dirname(filename), dir_infos)
|
content = _generate_content(path.dirname(filename), dir_infos, limit)
|
||||||
text = _instantiate_template(
|
text = _instantiate_template(
|
||||||
TEMPLATE, {'title': page_title, 'style': STYLE, 'content': content})
|
TEMPLATE, {'title': page_title, 'style': STYLE, 'content': content})
|
||||||
with codecs.open(filename, 'w', 'utf-8') as f:
|
with codecs.open(filename, 'w', 'utf-8') as f:
|
||||||
|
@ -280,6 +285,9 @@ def main():
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-t', '--titles', help='title, one per image dir', metavar='title',
|
'-t', '--titles', help='title, one per image dir', metavar='title',
|
||||||
nargs='*'),
|
nargs='*'),
|
||||||
|
parser.add_argument(
|
||||||
|
'-l', '--limit', help='limit to only sequences supported by first set',
|
||||||
|
action='store_true')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-de', '--default_ext', help='default extension', metavar='ext',
|
'-de', '--default_ext', help='default extension', metavar='ext',
|
||||||
default=_default_ext)
|
default=_default_ext)
|
||||||
|
@ -294,10 +302,10 @@ def main():
|
||||||
print 'added .html extension to filename:\n%s' % args.filename
|
print 'added .html extension to filename:\n%s' % args.filename
|
||||||
|
|
||||||
dir_infos = _get_dir_infos(
|
dir_infos = _get_dir_infos(
|
||||||
args.image_dirs, args.exts, args.prefixes, args.titles, args.default_ext,
|
args.image_dirs, args.exts, args.prefixes, args.titles,
|
||||||
args.default_prefix)
|
args.default_ext, args.default_prefix)
|
||||||
|
|
||||||
write_html_page(args.filename, args.page_title, dir_infos)
|
write_html_page(args.filename, args.page_title, dir_infos, args.limit)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Reference in a new issue