diff --git a/generate_emoji_html.py b/generate_emoji_html.py index 594382882..749eb1b1b 100755 --- a/generate_emoji_html.py +++ b/generate_emoji_html.py @@ -135,17 +135,17 @@ def _get_name(key_tuple, annotated_tuples): return CELL_PREFIX + seq_name -def _collect_aux_info(dir_infos, all_keys): +def _collect_aux_info(dir_infos, keys): """Returns a map from dir_info_index to a set of keys of additional images that we will take from the directory at that index.""" target_key_to_info_index = {} - for key in all_keys: + for key in keys: if len(key) == 1: continue for cp in key: target_key = tuple([cp]) - if target_key in all_keys or target_key in target_key_to_info_index: + if target_key in keys or target_key in target_key_to_info_index: continue for i, info in enumerate(dir_infos): if target_key in info.filemap: @@ -164,18 +164,18 @@ def _collect_aux_info(dir_infos, all_keys): def _generate_content( - basedir, font, dir_infos, limit, annotate, standalone, colors): - """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, - else absolute. If limit is true and there are multiple dirs, limit the set of - sequences to those in the first dir. If font is not none, generate columns - for the text rendered in the font before other columns. if annotate is - not none, highlight sequences that appear in this set.""" - - 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]) + basedir, font, dir_infos, keys, annotate, standalone, colors): + """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, else + absolute. If font is not none, generate columns for the text rendered in the + font before other columns. Dir_infos is the list of DirInfos in column + order. Keys is the list of canonical emoji sequences in row order. If + annotate is not none, highlight sequences that appear in this set. If + standalone is true, the image data and font (if used) will be copied under + the basedir to make a completely stand-alone page. Colors is the list of + background colors, the last DirInfo column will be repeated against each of + these backgrounds. + """ basedir = path.abspath(path.expanduser(basedir)) if not path.isdir(basedir): @@ -188,7 +188,7 @@ def _generate_content( # aren't part of main set. e.g. if we have female basketball player # color-3 we want female, basketball player, and color-3 images available # even if they aren't part of the target set. - aux_info = _collect_aux_info(dir_infos, all_keys) + aux_info = _collect_aux_info(dir_infos, keys) # create image subdirectories in target dir, copy image files to them, # and adjust paths @@ -198,8 +198,7 @@ def _generate_content( if not path.isdir(dstdir): os.mkdir(dstdir) - aux_keys = aux_info[i] - copy_keys = all_keys if not aux_keys else (all_keys | aux_keys) + copy_keys = set(keys) | aux_info[i] srcdir = info.directory filemap = info.filemap for key in copy_keys: @@ -230,7 +229,7 @@ def _generate_content( header_row.extend(['Sequence', 'Name']) lines.append('