예제 #1
0
def _get_keys(dir_infos, aliases, limit, all_emoji, emoji_sort, ignore_missing):
  """Return a list of the key tuples to display.  If all_emoji is
  true, start with all emoji sequences, else the sequences available
  in dir_infos (limited to the first dir_info if limit is True).
  If ignore_missing is true and all_emoji is false, ignore sequences
  that are not valid (e.g. skin tone variants of wrestlers).  If
  ignore_missing is true and all_emoji is true, ignore sequences
  for which we have no assets (e.g. newly defined emoji).  If not using
  all_emoji, aliases are included if we have a target for them.
  The result is in emoji order if emoji_sort is true, else in
  unicode codepoint order."""

  if all_emoji or ignore_missing:
    all_keys = unicode_data.get_emoji_sequences()
  if not all_emoji or ignore_missing:
    if len(dir_infos) == 1 or limit:
      avail_keys = frozenset(dir_infos[0].filemap.keys())
    else:
      avail_keys = _merge_keys([info.filemap for info in dir_infos])
    if aliases:
      avail_keys = _add_aliases(avail_keys, aliases)

  if not ignore_missing:
    keys = all_keys if all_emoji else avail_keys
  else:
    keys = set(all_keys) & avail_keys

  if emoji_sort:
    sorted_keys = unicode_data.get_sorted_emoji_sequences(keys)
  else:
    sorted_keys = sorted(keys)
  return sorted_keys
예제 #2
0
def _get_keys(dir_infos, limit, all_emoji, emoji_sort):
    """Return a list of the key tuples to display.  If all_emoji is
  True, returns all emoji sequences, else the sequences available
  in dir_infos (limited to the first dir_info if limit is True).
  The result is in emoji order if emoji_sort is true, else in
  unicode codepoint order."""
    if all_emoji:
        keys = unicode_data.get_emoji_sequences()
    elif len(dir_infos) == 1 or limit:
        keys = frozenset(dir_infos[0].filemap.keys())
    else:
        keys = _merge_keys([info.filemap for info in dir_infos])
    if emoji_sort:
        sorted_keys = unicode_data.get_sorted_emoji_sequences(keys)
    else:
        sorted_keys = sorted(keys)
    return sorted_keys