Exemple #1
0
 def _get_part(cp):
     if cp == 0x200d:  # zwj, common so replace with '+'
         return '+'
     if unicode_data.is_regional_indicator(cp):
         return unicode_data.regional_indicator_to_ascii(cp)
     if unicode_data.is_tag(cp):
         return unicode_data.tag_character_to_ascii(cp)
     fname = _get_filepath(cp)
     if fname:
         return '<img src="%s">' % fname
     raise Exception()
def _standard_name(seq):
    """Use the standard emoji name, with some algorithmic modifications.

  We want to ignore skin-tone modifiers (but of course if the sequence _is_
  the skin-tone modifier itself we keep that).  So we strip these so we can
  start with the generic name ignoring skin tone.

  Non-emoji that are turned into emoji using the emoji VS have '(emoji) '
  prepended to them, so strip that.

  Regional indicator symbol names are a bit long, so shorten them.

  Regional sequences are assumed to be ok as-is in terms of capitalization and
  punctuation, so no modifications are applied to them.

  After title-casing we make some English articles/prepositions lower-case
  again.  We also replace '&' with 'and'; Unicode seems rather fond of
  ampersand."""

    if not unicode_data.is_skintone_modifier(seq[0]):
        seq = tuple(
            [cp for cp in seq if not unicode_data.is_skintone_modifier(cp)])
    name = unicode_data.get_emoji_sequence_name(seq)

    if name.startswith('(emoji) '):
        name = name[8:]

    if len(seq) == 1 and unicode_data.is_regional_indicator(seq[0]):
        return 'Regional Symbol ' + unicode_data.regional_indicator_to_ascii(
            seq[0])

    if (unicode_data.is_regional_indicator_seq(seq)
            or unicode_data.is_regional_tag_seq(seq)):
        return name

    name = name.title()
    # Require space delimiting just in case...
    name = re.sub(r'\s&\s', ' and ', name)
    name = re.sub(
        # not \b at start because we retain capital at start of phrase
        r'(\s(:?A|And|From|In|Of|With|For))\b',
        lambda s: s.group(1).lower(),
        name)

    return name
def _standard_name(seq):
  """Use the standard emoji name, with some algorithmic modifications.

  We want to ignore skin-tone modifiers (but of course if the sequence _is_
  the skin-tone modifier itself we keep that).  So we strip these so we can
  start with the generic name ignoring skin tone.

  Non-emoji that are turned into emoji using the emoji VS have '(emoji) '
  prepended to them, so strip that.

  Regional indicator symbol names are a bit long, so shorten them.

  Regional sequences are assumed to be ok as-is in terms of capitalization and
  punctuation, so no modifications are applied to them.

  After title-casing we make some English articles/prepositions lower-case
  again.  We also replace '&' with 'and'; Unicode seems rather fond of
  ampersand."""

  if not unicode_data.is_skintone_modifier(seq[0]):
    seq = tuple([cp for cp in seq if not unicode_data.is_skintone_modifier(cp)])
  name = unicode_data.get_emoji_sequence_name(seq)

  if name.startswith('(emoji) '):
    name = name[8:]

  if len(seq) == 1 and unicode_data.is_regional_indicator(seq[0]):
    return 'Regional Symbol ' + unicode_data.regional_indicator_to_ascii(seq[0])

  if (unicode_data.is_regional_indicator_seq(seq) or
      unicode_data.is_regional_tag_seq(seq)):
    return name

  name = name.title()
  # Require space delimiting just in case...
  name = re.sub(r'\s&\s', ' and ', name)
  name = re.sub(
      # not \b at start because we retain capital at start of phrase
      r'(\s(:?A|And|From|In|Of|With|For))\b', lambda s: s.group(1).lower(),
      name)

  return name