Merge pull request #114 from dougfelt/legacy_android

Legacy android
This commit is contained in:
dougfelt 2017-04-25 13:02:45 -07:00 committed by GitHub
commit ff566b2c16
3 changed files with 43 additions and 15 deletions

View file

@ -35,6 +35,11 @@ def seq_to_str(seq):
return '_'.join('%04x' % cp for cp in seq) return '_'.join('%04x' % cp for cp in seq)
def read_default_unknown_flag_aliases():
unknown_flag_path = path.join(DATA_ROOT, 'unknown_flag_aliases.txt')
return read_emoji_aliases(unknown_flag_path)
def read_default_emoji_aliases(): def read_default_emoji_aliases():
alias_path = path.join(DATA_ROOT, 'emoji_aliases.txt') alias_path = path.join(DATA_ROOT, 'emoji_aliases.txt')
return read_emoji_aliases(alias_path) return read_emoji_aliases(alias_path)

View file

@ -253,3 +253,11 @@ fe82b;unknown_flag # no name -> no name
1f9dd_1f3ff;1f9dd_1f3ff_200d_2640 # dark skin tone 1f9dd_1f3ff;1f9dd_1f3ff_200d_2640 # dark skin tone
1f9de;1f9de_200d_2640 # GENIE -> female genie 1f9de;1f9de_200d_2640 # GENIE -> female genie
1f9df;1f9df_200d_2640 # ZOMBIE -> female zombie 1f9df;1f9df_200d_2640 # ZOMBIE -> female zombie
# legacy android sequences
# wrestlers -> men wrestling
1f93c_1f3fb;1f93c_1f3fb_200d_2642 # light skin tone
1f93c_1f3fc;1f93c_1f3fc_200d_2642 # medium-light skin tone
1f93c_1f3fd;1f93c_1f3fd_200d_2642 # medium skin tone
1f93c_1f3fe;1f93c_1f3fe_200d_2642 # medium-dark skin tone
1f93c_1f3ff;1f93c_1f3ff_200d_2642 # dark skin tone

View file

@ -58,15 +58,18 @@ def _merge_keys(dicts):
return frozenset(keys) return frozenset(keys)
def _generate_row_cells(key, font, aliases, dir_infos, basepaths, colors): def _generate_row_cells(
key, font, aliases, excluded, dir_infos, basepaths, colors):
CELL_PREFIX = '<td>' CELL_PREFIX = '<td>'
indices = range(len(basepaths)) indices = range(len(basepaths))
def _cell(info, basepath): def _cell(info, basepath):
if key in info.filemap: if key in info.filemap:
return '<img src="%s">' % path.join(basepath, info.filemap[key]) return '<img src="%s">' % path.join(basepath, info.filemap[key])
if key in aliases: if key in aliases:
return '-alias-' return 'alias'
return '-missing-' if key in excluded:
return 'exclude'
return 'missing'
def _text_cell(text_dir): def _text_cell(text_dir):
text = ''.join(unichr(cp) for cp in key) text = ''.join(unichr(cp) for cp in key)
@ -184,17 +187,20 @@ def _collect_aux_info(dir_infos, keys):
def _generate_content( def _generate_content(
basedir, font, dir_infos, keys, aliases, annotations, standalone, colors): basedir, font, dir_infos, keys, aliases, excluded, annotations, standalone,
colors):
"""Generate an html table for the infos. Basedir is the parent directory of """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 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 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 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 order. Keys is the list of canonical emoji sequences in row order. Aliases
annotations is not none, highlight sequences that appear in this map based on and excluded indicate images we expect to not be present either because
their map values ('ok', 'error', 'warning'). If standalone is true, the they are aliased or specifically excluded. If annotations is not none,
image data and font (if used) will be copied under the basedir to make a highlight sequences that appear in this map based on their map values ('ok',
completely stand-alone page. Colors is the list of background colors, the 'error', 'warning'). If standalone is true, the image data and font (if used)
last DirInfo column will be repeated against each of these backgrounds. 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)) basedir = path.abspath(path.expanduser(basedir))
@ -250,7 +256,8 @@ def _generate_content(
lines.append('<th>'.join(header_row)) lines.append('<th>'.join(header_row))
for key in keys: for key in keys:
row = _generate_row_cells(key, font, aliases, dir_infos, basepaths, colors) row = _generate_row_cells(
key, font, aliases, excluded, dir_infos, basepaths, colors)
row.append(_get_desc(key, aliases, dir_infos, basepaths)) row.append(_get_desc(key, aliases, dir_infos, basepaths))
row.append(_get_name(key, annotations)) row.append(_get_name(key, annotations))
lines.append(''.join(row)) lines.append(''.join(row))
@ -482,7 +489,7 @@ STYLE = """
""" """
def write_html_page( def write_html_page(
filename, page_title, font, dir_infos, keys, aliases, annotations, filename, page_title, font, dir_infos, keys, aliases, excluded, annotations,
standalone, colors, info): standalone, colors, info):
out_dir = path.dirname(filename) out_dir = path.dirname(filename)
@ -508,8 +515,8 @@ def write_html_page(
font = path.normpath(path.join(common_prefix, rel_font)) font = path.normpath(path.join(common_prefix, rel_font))
content = _generate_content( content = _generate_content(
path.dirname(filename), font, dir_infos, keys, aliases, annotations, path.dirname(filename), font, dir_infos, keys, aliases, excluded,
standalone, colors) annotations, standalone, colors)
N_STYLE = STYLE N_STYLE = STYLE
if font: if font:
FONT_FACE_STYLE = """ FONT_FACE_STYLE = """
@ -540,6 +547,12 @@ def _get_canonical_aliases():
aliases = add_aliases.read_default_emoji_aliases() aliases = add_aliases.read_default_emoji_aliases()
return {canon(k): canon(v) for k, v in aliases.iteritems()} return {canon(k): canon(v) for k, v in aliases.iteritems()}
def _get_canonical_excluded():
def canon(seq):
return unicode_data.get_canonical_emoji_sequence(seq) or seq
aliases = add_aliases.read_default_unknown_flag_aliases()
return frozenset([canon(k) for k in aliases.keys()])
def main(): def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
@ -614,11 +627,13 @@ def main():
dir_infos, aliases, args.limit, args.all_emoji, args.emoji_sort, dir_infos, aliases, args.limit, args.all_emoji, args.emoji_sort,
args.ignore_missing) args.ignore_missing)
excluded = _get_canonical_excluded()
info = _generate_info_text(args) info = _generate_info_text(args)
write_html_page( write_html_page(
args.outfile, args.page_title, args.font, dir_infos, keys, aliases, args.outfile, args.page_title, args.font, dir_infos, keys, aliases,
annotations, args.standalone, args.colors, info) excluded, annotations, args.standalone, args.colors, info)
if __name__ == "__main__": if __name__ == "__main__":