当前位置: 首页>>代码示例>>Python>>正文


Python Emoji.shortcode_to_image方法代码示例

本文整理汇总了Python中emojipy.Emoji.shortcode_to_image方法的典型用法代码示例。如果您正苦于以下问题:Python Emoji.shortcode_to_image方法的具体用法?Python Emoji.shortcode_to_image怎么用?Python Emoji.shortcode_to_image使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在emojipy.Emoji的用法示例。


在下文中一共展示了Emoji.shortcode_to_image方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_shortcode_to_image

# 需要导入模块: from emojipy import Emoji [as 别名]
# 或者: from emojipy.Emoji import shortcode_to_image [as 别名]
 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,代码行数:10,代码来源:test_emojione.py

示例2: test_shortcode_to_image

# 需要导入模块: from emojipy import Emoji [as 别名]
# 或者: from emojipy.Emoji import shortcode_to_image [as 别名]
 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,代码行数:12,代码来源:test_emojione.py

示例3: test_emoji_at_end_of_sentence_with_preceeding_colon

# 需要导入模块: from emojipy import Emoji [as 别名]
# 或者: from emojipy.Emoji import shortcode_to_image [as 别名]
 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,代码行数:12,代码来源:test_conversion.py

示例4: test_emoji_at_start_of_sentence_with_apostrophe

# 需要导入模块: from emojipy import Emoji [as 别名]
# 或者: from emojipy.Emoji import shortcode_to_image [as 别名]
 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,代码行数:12,代码来源:test_conversion.py

示例5: test_emoji_inside_sentence_with_comma

# 需要导入模块: from emojipy import Emoji [as 别名]
# 或者: from emojipy.Emoji import shortcode_to_image [as 别名]
 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,代码行数:12,代码来源:test_conversion.py

示例6: test_emoji_at_start_of_sentence

# 需要导入模块: from emojipy import Emoji [as 别名]
# 或者: from emojipy.Emoji import shortcode_to_image [as 别名]
 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,代码行数:12,代码来源:test_conversion.py

示例7: test_emoji_at_end_of_sentence_with_alternate_punctuation

# 需要导入模块: from emojipy import Emoji [as 别名]
# 或者: from emojipy.Emoji import shortcode_to_image [as 别名]
 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,代码行数:12,代码来源:test_conversion.py

示例8: test_single_unicode_char

# 需要导入模块: from emojipy import Emoji [as 别名]
# 或者: from emojipy.Emoji import shortcode_to_image [as 别名]
 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,代码行数:12,代码来源:test_conversion.py

示例9: emoji_replace

# 需要导入模块: from emojipy import Emoji [as 别名]
# 或者: from emojipy.Emoji import shortcode_to_image [as 别名]
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,代码行数:23,代码来源:pifti.py

示例10: test_emoji_inside_object_tag

# 需要导入模块: from emojipy import Emoji [as 别名]
# 或者: from emojipy.Emoji import shortcode_to_image [as 别名]
 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,代码行数:6,代码来源:test_conversion.py

示例11: test_emoji_inside_img_tag

# 需要导入模块: from emojipy import Emoji [as 别名]
# 或者: from emojipy.Emoji import shortcode_to_image [as 别名]
 def test_emoji_inside_img_tag(self):
     unicode = 'The <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png" /> 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,代码行数:6,代码来源:test_conversion.py

示例12: test_emoji_at_start_of_sentence

# 需要导入模块: from emojipy import Emoji [as 别名]
# 或者: from emojipy.Emoji import shortcode_to_image [as 别名]
 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/3.1/png/64/1f40c.png"/> mail.'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
开发者ID:Ranks,项目名称:emojione,代码行数:8,代码来源:test_conversion.py

示例13: test_emoji_at_start_of_sentence_with_apostrophe

# 需要导入模块: from emojipy import Emoji [as 别名]
# 或者: from emojipy.Emoji import shortcode_to_image [as 别名]
 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:Happy-Ferret,项目名称:emojione,代码行数:8,代码来源:test_conversion.py

示例14: test_single_unicode_char

# 需要导入模块: from emojipy import Emoji [as 别名]
# 或者: from emojipy.Emoji import shortcode_to_image [as 别名]
 def test_single_unicode_char(self):
     unicode = '🐌'
     shortcode = ':snail:'
     image = '<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,代码行数:8,代码来源:test_conversion.py

示例15: test_emoji_inside_sentence_with_comma

# 需要导入模块: from emojipy import Emoji [as 别名]
# 或者: from emojipy.Emoji import shortcode_to_image [as 别名]
 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="//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:launchyard,项目名称:emojipy,代码行数:8,代码来源:test_conversion.py


注:本文中的emojipy.Emoji.shortcode_to_image方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。