当前位置: 首页>>代码示例>>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;未经允许,请勿转载。