Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
def replace_with_emoji_pdf(text, size):
    """
    Reportlab's Paragraph doesn't accept normal html <image> tag's attributes
    like 'class', 'alt'. Its a little hack to remove those attrbs
    """

    text = Emoji.to_image(text)
    text = text.replace('class="emojione"', 'height=%s width=%s' %(size, size))
    return re.sub('alt="'+Emoji.shortcode_regexp+'"', '', text)
Exemplo n.º 5
0
def emoji2cfd(emoji, emoji_width = 1):
    '''
    Converts the inputted emoji to numpy array and feeds it into image2cdf.
    The emoji_width parameter helps scale the emoji properly for the cfd solver

    '''

    emoji_img_item = Emoji.to_image(emoji)
    start = a.find("src=")
    link = a[start+5: -3]
    im = imageio.imread(link)
Exemplo n.º 6
0
def emoji2cdf(emoji, emoji_width=1):
    '''
    Converts the inputted emoji to numpy array and feeds it into image2cdf.
    The emoji_width parameter helps scale the emoji properly for the cfd solver
    
    '''
    emoji_img_item = Emoji.to_image(emoji)
    start = a.find("src=")
    link = a[start + 5:-3]
    im = imageio.imread(link)

    aerodynamics = {
        'coefficient_of_drag': .3,
        'coefficient_of_lift': 1,
        'wing_area': 1,
        'frontal_area': .2,
        'properties': 1
    }
    return aerodynamics
Exemplo n.º 7
0
def bullImage():
    rawHTML = Emoji.to_image("\U0001F402")
    downloadedImage = image(rawHTML)

    return downloadedImage
Exemplo n.º 8
0
def bearImage():
    rawHTML = Emoji.to_image("\U0001F43B")
    downloadedImage = image(rawHTML)

    return downloadedImage
Exemplo n.º 9
0
def rainbowImage():
    rawHTML = Emoji.to_image("\U0001F308")
    downloadedImage = image(rawHTML)

    return downloadedImage
Exemplo n.º 10
0
def emoji2image(emoji):
    a = Emoji.to_image(emoji)
    url = a[a.find("src=")+5:a.find("/>")-1]
    image = imageio.imread(url)
    return image
Exemplo n.º 11
0
def replace_with_emoji_pdf(text, size):
    text = Emoji.to_image(text)
    text = text.replace('class="emojione"',
                        'height=%s width=%s' % (size, size))
    return re.sub(u'(alt=".{,5}")|([^\x00-\x7F]+)', '', text)
def to_image(text, **kwargs):
    return Emoji.to_image(text, **kwargs)