當前位置: 首頁>>代碼示例>>Python>>正文


Python emojipy.Emoji類代碼示例

本文整理匯總了Python中emojipy.Emoji的典型用法代碼示例。如果您正苦於以下問題:Python Emoji類的具體用法?Python Emoji怎麽用?Python Emoji使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Emoji類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_shortcode_to_image

 def test_shortcode_to_image(self):
     txt = 'Hello world! 😄 :smile:'
     expected = """Hello world! 😄 <img class="emojione" alt="😄" src="https://cdn.jsdelivr.net/emojione/assets/3.1/png/64/1f604.png"/>"""
     self.assertEqual(Emoji.shortcode_to_image(txt), expected)
     Emoji.unicode_alt = False
     expected = """Hello world! 😄 <img class="emojione" alt=":smile:" src="https://cdn.jsdelivr.net/emojione/assets/3.1/png/64/1f604.png"/>"""
     self.assertEqual(Emoji.shortcode_to_image(txt), expected)
     Emoji.unicode_alt = True
開發者ID:Ranks,項目名稱:emojione,代碼行數:8,代碼來源:test_emojione.py

示例2: test_single_unicode_char

 def test_single_unicode_char(self):
     unicode = "🐌"
     shortcode = ":snail:"
     image = (
         '<img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png'
         + self.cache_bust_param
         + '"/>'
     )
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
開發者ID:Ranks,項目名稱:emojione,代碼行數:10,代碼來源:test_conversion.py

示例3: test_emoji_inside_sentence_with_comma

 def test_emoji_inside_sentence_with_comma(self):
     unicode = "The 🐌, is Emoji One's official mascot."
     shortcode = "The :snail:, is Emoji One's official mascot."
     image = (
         'The <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png'
         + self.cache_bust_param
         + "\"/>, is Emoji One's official mascot."
     )
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
開發者ID:Ranks,項目名稱:emojione,代碼行數:10,代碼來源:test_conversion.py

示例4: test_emoji_at_start_of_sentence

 def test_emoji_at_start_of_sentence(self):
     unicode = "🐌 mail."
     shortcode = ":snail: mail."
     image = (
         '<img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png'
         + self.cache_bust_param
         + '"/> mail.'
     )
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
開發者ID:Ranks,項目名稱:emojione,代碼行數:10,代碼來源:test_conversion.py

示例5: test_emoji_at_start_of_sentence_with_apostrophe

 def test_emoji_at_start_of_sentence_with_apostrophe(self):
     unicode = "🐌's are cool!"
     shortcode = ":snail:'s are cool!"
     image = (
         '<img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png'
         + self.cache_bust_param
         + "\"/>'s are cool!"
     )
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
開發者ID:Ranks,項目名稱:emojione,代碼行數:10,代碼來源:test_conversion.py

示例6: test_emoji_at_end_of_sentence_with_alternate_punctuation

 def test_emoji_at_end_of_sentence_with_alternate_punctuation(self):
     unicode = "Emoji One's official mascot is 🐌!"
     shortcode = "Emoji One's official mascot is :snail:!"
     image = (
         'Emoji One\'s official mascot is <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png'
         + self.cache_bust_param
         + '"/>!'
     )
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
開發者ID:Ranks,項目名稱:emojione,代碼行數:10,代碼來源:test_conversion.py

示例7: test_shortcode_to_image

 def test_shortcode_to_image(self):
     txt = 'Hello world! 😄 :smile:'
     expected = """Hello world! 😄 <img class="emojione" alt="😄" src="//cdn.jsdelivr.net/emojione/assets/png/1F604.png%s"/>""" %\
                Emoji.cache_bust_param
     self.assertEqual(Emoji.shortcode_to_image(txt), expected)
     Emoji.unicode_alt = False
     expected = """Hello world! 😄 <img class="emojione" alt=":smile:" src="//cdn.jsdelivr.net/emojione/assets/png/1F604.png%s"/>""" %\
                Emoji.cache_bust_param
     self.assertEqual(Emoji.shortcode_to_image(txt), expected)
     Emoji.unicode_alt = True
開發者ID:oliciv,項目名稱:emojipy,代碼行數:10,代碼來源:test_emojione.py

示例8: test_emoji_at_end_of_sentence_with_preceeding_colon

 def test_emoji_at_end_of_sentence_with_preceeding_colon(self):
     unicode = "Emoji One's official mascot: 🐌"
     shortcode = "Emoji One's official mascot: :snail:"
     image = (
         'Emoji One\'s official mascot: <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png'
         + self.cache_bust_param
         + '"/>'
     )
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
開發者ID:Ranks,項目名稱:emojione,代碼行數:10,代碼來源:test_conversion.py

示例9: replace_with_emoji

def replace_with_emoji(effect, size):
    """
    Reportlab's Paragraph doesn't accept normal html <image> tag's attributes
    like 'class', 'alt'. Its a little hack to remove those attrbs
    """
    e = ""
    for i, c in enumerate(effect):
        if c in emoji.UNICODE_EMOJI:
            e += Emoji.to_image(c)
        else:
            e += c
    
#    e = effect
#    for item in sorted(emoji.UNICODE_EMOJI.keys(), key = len, reverse = True):
#        if item in effect:
#            print(item)
#            if Emoji.to_image(item) != item:
#                e = re.sub(item, Emoji.to_image(item), e)
#        print(item)
#        Emoji.to_image(c)
#        e = re.sub(re.escape(item), re.escape(emoji.UNICODE_EMOJI[item]), e)
    
    e = e.replace('class="emojione " style="" ', 'height=%s width=%s' %
                        (size, size))
    return re.sub('alt="'+Emoji.shortcode_regexp+'"', '', e)
開發者ID:robertkck,項目名稱:world-control,代碼行數:25,代碼來源:module.py

示例10: to_image

def to_image(text, **kwargs):
    """
    Parse short code and unicode code to emotion
    :param text:
    :param kwargs[css]: css class
    :param kwargs[style]: icon stylesheet
    :return: string
    """
    return Emoji.to_image(text, **kwargs)
開發者ID:phuong,項目名稱:django-emojione,代碼行數:9,代碼來源:functions.py

示例11: test_shortcode_to_ascii

    def test_shortcode_to_ascii(self):
        txt = 'Hello world! 😄 :slight_smile:'
        expected = [
            'Hello world! 😄 :]',
            'Hello world! 😄 :-)',
            'Hello world! 😄 =)',
            'Hello world! 😄 :)',
            'Hello world! 😄 =]'
        ]

        output = Emoji.shortcode_to_ascii(txt)
        self.assertIn(output, expected)
開發者ID:Andrey-Temchenko,項目名稱:emojione,代碼行數:12,代碼來源:test_emojione.py

示例12: emoji_replace

def emoji_replace(text, autoescape=True):
    """
    Replaces Unicode and Shortcode emoji's with embedded images,
    using the Emojipy library

    Args:
        text: A string to be matched for shortcode and unicode emojis
        autoescape: Optional argument for autoescaping of input string before processing

    Returns:
        Safe text
    """
    # Escape text if it is not safe
    autoescape = autoescape and not isinstance(text, SafeData)
    if autoescape:
        text = escape(text)

    text = Emoji.unicode_to_image(text)
    text = Emoji.shortcode_to_image(text)

    return mark_safe(text)
開發者ID:arcynum,項目名稱:pifti,代碼行數:21,代碼來源:pifti.py

示例13: test_emoji_at_end_of_sentence_with_alternate_punctuation

 def test_emoji_at_end_of_sentence_with_alternate_punctuation(self):
     unicode = 'EmojiOne\'s original mascot is 🐌!'
     shortcode = 'EmojiOne\'s original mascot is :snail:!'
     image = 'EmojiOne\'s original mascot is <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/3.1/png/64/1f40c.png"/>!'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
開發者ID:Ranks,項目名稱:emojione,代碼行數:6,代碼來源:test_conversion.py

示例14: test_emoji_at_end_of_sentence_with_preceeding_colon

 def test_emoji_at_end_of_sentence_with_preceeding_colon(self):
     unicode = 'EmojiOne\'s original mascot: 🐌'
     shortcode = 'EmojiOne\'s original mascot: :snail:'
     image = 'EmojiOne\'s original mascot: <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/3.1/png/64/1f40c.png"/>'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
開發者ID:Ranks,項目名稱:emojione,代碼行數:6,代碼來源:test_conversion.py

示例15: test_emoji_inside_object_tag

 def test_emoji_inside_object_tag(self):
     unicode = 'The <object class="emojione" data="//cdn.jsdelivr.net/emojione/assets/svg/1f40c.svg" type="image/svg+xml" standby="🐌">🐌</object> is Emoji One\'s official mascot'
     self.assertEqual(Emoji.unicode_to_image(unicode), unicode)
     self.assertEqual(Emoji.shortcode_to_image(unicode), unicode)
開發者ID:Ranks,項目名稱:emojione,代碼行數:4,代碼來源:test_conversion.py


注:本文中的emojipy.Emoji類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。