def gifs2lossy(self): emoji_dict = { Emoji(emoji).filename: Emoji(emoji) for emoji in self.files_in_folder(self.project_folder) if Emoji(emoji) } for index, item in enumerate(emoji_dict.keys()): if not emoji_dict[item].has_lossy or settings.overwrite_gifs: print(emoji_dict[item].name, 'lossy file missing, creating one') # Get the proper lossy value for the gifsicle if '136' in emoji_dict[item].resolution: lossy_factor = self.lossy_factor['136'] elif '280' in emoji_dict[item].resolution: lossy_factor = self.lossy_factor['280'] GifSicle(emoji_dict[item], lossy_factor, self.color_map, to_lossy=True) self.conversion2.emit(index + 1, len(emoji_dict) - 1) else: print( 'Lossy file for {} already exists, skipping lossy creation' .format(emoji_dict[item].name)) QTimer.singleShot(1, self.conversion2_done)
def escape_message(dat: dict) -> None: ''' Escapes message for safe rendering ''' if 'title' in dat: if dat['title'] is None: del dat['title'] else: dat['title'] = Emoji.replace_unicode(html.escape(dat['title'])) if 'content' in dat: if dat['content'] is None: del dat['content'] else: if dat.get('parse_mode') == 'html': dat['content'] = Emoji.replace_unicode(dat['content']) else: dat['content'] = Emoji.replace_unicode( html.escape(dat['content'])) for btn in dat.get('buttons', []): try: btn['data']['title'] = Emoji.replace_unicode( html.escape(btn['data']['title'])) except KeyError: pass for btn in dat.get('quick_replies', []): try: btn['title'] = Emoji.replace_unicode(html.escape(btn['title'])) except KeyError: # pragma: nocoverage pass
def main(): emojis = [Emoji("smiley"), Emoji("frowny"), Emoji("angry")] for emoji in emojis: emoji.displayRed(sense) emoji.displayGreen(sense) emoji.displayBlue(sense)
def handbrake(self): emoji_list = [ Emoji(emoji) for emoji in self.files_in_folder(self.project_folder) if Emoji(emoji) ] Handbrake(emoji_list[0]) self.conversion4.emit(1, 1) QTimer.singleShot(1, self.conversion4_done)
def avis2gif(self): emoji_dict = { Emoji(emoji).filename: Emoji(emoji) for emoji in self.files_in_folder(self.project_folder) if Emoji(emoji) } for index, item in enumerate(emoji_dict.keys()): # print(emoji_dict[item]) if not emoji_dict[item].has_gif or settings.overwrite_gifs: print(emoji_dict[item].name, 'gif file missing, creating one') FFmpeg(emoji_dict[item]) self.conversion1.emit(index + 1, len(emoji_dict) - 1) QTimer.singleShot(1, self.conversion1_done)
def btn_update_clicked(): if self.embedded or self.scroll_lock: f = QFileDialog.getOpenFileName(self, 'Select image to load', '.', "All Files (*.*)", "All Files (*.*)") if f: self.load(f[0]) else: if isinstance(self.opened_image, str): # If we give a string it makes it to Emoji self.opened_image = Emoji(self.opened_image) if isinstance(self.opened_image, Emoji): working_file = self.opened_image.gif_path output_file = self.opened_image.temp_path else: raise ValueError('Update button received not Emoji or str') self.movie.stop() lossy_factor = self.spin_quality.text() # Instead of generating a txt file for a colortable # color_table = act_reader.create_gifsicle_colormap(self.dropdown_colortable.currentText()) color_table_path = path.join('.', 'current_act.txt') # Get a handle on color table QPlainTextEdit plaintext_act_readout = self.parentWidget().findChildren(QPlainTextEdit, 'plaintext_act_readout')[0] # We generate a colormap from the colormap viewer window with open(color_table_path, 'w') as txt: txt.writelines(plaintext_act_readout.toPlainText()) self.gc = GifSicle(self.opened_image, lossy_factor, color_table_path) print(self.gc, self.opened_image, lossy_factor, color_table_path) self.load(output_file) temp_file_size = path.getsize(output_file)/1024 self.TO_STATUS_BAR.emit('Resulting filesize is: {:.2f} Kb'.format(temp_file_size))
def emoji_replace_html_entities(value, autoescape=None): # Replaced before because it needs unescaped & value = Emoji.replace_html_entities(value) autoescape = autoescape and not isinstance(value, SafeData) if autoescape: value = escape(value) return mark_safe(value)
def my_rant(request, rant_id): ''' View function to display the current user's single rant in full with the rant's reactions ''' try: current_user = request.user current_rant = Rant.get_single_rant(rant_id) title = f'{current_rant.author.user.username}\'s Rant' current_rant_reactions = Reaction.get_rant_reactions(rant_id) rant_reaction_emojis = [] for current_rant_reaction in current_rant_reactions: current_rant_reaction_icon = Emoji.replace( ':' + current_rant_reaction.emoji_title + ':') rant_reaction_emojis.append(current_rant_reaction_icon) return render( request, 'all-rants/my-rant.html', { "title": title, "rant": current_rant, "current_rant_reactions": rant_reaction_emojis }) except ObjectDoesNotExist: return redirect(index)
def make_video_list(self, folder=None, ext='avi'): # If no folder specified, update the current working directory if not folder: folder = self.working_directory if len(files_in_folder(folder, ext)) > 0: # Make a dictionary out of emojis, when emoji object is not none (has been successfully created) emoji_dict = { Emoji(emoji).filename: Emoji(emoji) for emoji in files_in_folder(folder, ext) if Emoji(emoji) } # Make a model self.videolist_model = VideoListModel(emoji_dict) # Assign the model to the list view self.list_videoslist.setModel(self.videolist_model) # Enable the collect button self.btn_clean.setEnabled(True)
def single_rant(request, rant_id): ''' View function to display a specific rant in page of its own ''' try: single_rant = Rant.get_single_rant(rant_id) title = f'{single_rant.author.user.username}\'s Rant' emoji_names = Emoji.keys() emoji_icons = [] for emoji_name in emoji_names: emoji_icon = Emoji.replace(':' + emoji_name + ':') emoji_icons.append(emoji_icon) continue # print(emoji_icons[0:4]) rant_reaction_emojis = [] rant_reactions = Reaction.get_rant_reactions(single_rant.id) for rant_reaction in rant_reactions: rant_reaction_icon = Emoji.replace(':' + rant_reaction.emoji_title + ':') rant_reaction_emojis.append(rant_reaction_icon) # print(rant_reaction_emojis) return render( request, 'all-rants/single-rant.html', { "title": title, "rant": single_rant, "emoji_names": emoji_names, "emoji_icons": emoji_icons, "rant_reaction_emojis": rant_reaction_emojis }) except ObjectDoesNotExist: return redirect(index)
def update_emojis(emojis, dir, emoji): name, url = emoji.name, emoji.url if any([e.name == name for e in emojis]): return emojis else: emojis.add(Emoji(name, url, dir)) return emojis
def __action(self): if self.__status == 2: # game ended data = 'final\n' + str(self.__myScore) + '\n' try: self.__net.sendData(data) except: pass self.__musicPlayer.stop() return try: if self.__isServer == True: # remove emoji if its status is 2 (out) i = 0 self.__myEmojiListLock.acquire() while i < len(self.__myEmojiList): if self.__myEmojiList[i].getStatus() == 2: del self.__myEmojiList[i] continue i = i + 1 # randomly generate emoji and append to myEmojiList self.__randomGenEmoji() for emoji in self.__emojiList: newEmoji = Emoji(emoji.getX() + self.myOffsetX, emoji.getY() + self.myOffsetY, emoji.getType()) self.__myEmojiList.append(newEmoji) self.__myEmojiListLock.release() # send new emojiList data = 'new\n' for emoji in self.__emojiList: data = data + emoji.toString() + '\n' self.__net.sendData(data) # send our score data = 'score\n' + str(self.__myScore) + '\n' self.__net.sendData(data) else: # remove emoji if its status is 2 (out) i = 0 self.__myEmojiListLock.acquire() while i < len(self.__myEmojiList): if self.__myEmojiList[i].getStatus() == 2: del self.__myEmojiList[i] continue i = i + 1 self.__myEmojiListLock.release() # send score to enemy data = 'score\n' + str(self.__myScore) + '\n' self.__net.sendData(data) self.__actioner = threading.Timer(0.8, self.__action) self.__actioner.start() except Exception as e: print('error in __action():', e)
def __randomGenEmoji(self): if len(self.__emojiList) >= self.maxEmojiNum: return else: tempList = [] for i in range(self.maxEmojiGen): tempList.append( Emoji(random.randint(0, self.maxX), 0, random.randint(1, Emoji.SURPRISE))) self.__emojiList = tempList
def expand_tweet_urls(tweet): """ Replace shortened URLs with long URLs in the twitter status Should be used before urlize_tweet """ text = tweet.full_text urls = tweet.urls for url in urls: text = text.replace(url.url, '<a href="%s" target="_blank">%s</a>' % (url.expanded_url, url.url)) tweet.full_text = Emoji.replace_unicode(text) return tweet
class Meta: model = models.Private_Message fields = [ 'target_user_id', 'content', 'media_attachment', 'private_message_id' ] widgets = { 'private_message_id': forms.HiddenInput(), 'content': forms.Textarea(attrs={'onkeypress': Emoji.names()}) }
def gifs2damaged(self): emoji_dict = { Emoji(emoji).filename: Emoji(emoji) for emoji in self.files_in_folder(self.project_folder) if Emoji(emoji) } for index, item in enumerate(emoji_dict.keys()): if not emoji_dict[item].has_damaged or settings.overwrite_gifs: print(emoji_dict[item].name, 'damaged file missing, creating') # Get the proper lossy value for the gifsicle if '136' in emoji_dict[item].resolution: lossy_factor = self.lossy_factor['136'] elif '280' in emoji_dict[item].resolution: lossy_factor = self.lossy_factor['280'] GifSicle(emoji_dict[item], lossy_factor, self.color_map, to_damaged=True) self.conversion3.emit(index + 1, len(emoji_dict) - 1) QTimer.singleShot(1, self.conversion3_done)
def __handleData(self, data): data = data.rstrip().split('\n') if data[0] == 'new': for emojiData in data[1:]: emoji = Emoji.parseString(emojiData) emoji.setX(emoji.getX() + self.ui.myOffsetX) emoji.setY(emoji.getY() + self.ui.myOffsetY) self.ui.myEmojiAdd(emoji) elif data[0] == 'score': self.ui.setEnemyScore(int(data[1])) elif data[0] == 'final': self.ui.setEnemyScore(int(data[1])) self.ui.gameEnd.emit()
def get_context_data(self, **kwargs): context = (super(EmojiTestReplaceTagView, self) .get_context_data(**kwargs)) limit = int(self.request.GET.get('limit', 0)) emojis = [] for i, emoji in enumerate(sorted(Emoji.keys())): if limit and i >= limit: break emojis.append(':{0}:'.format(emoji)) context['emojis'] = emojis return context
class Meta: model = models.Twitter_Tweet fields = [ 'content', 'author_id', 'media_attachment', 'tweet_id', 'encrypted_content', 'content_key', 'replies', 'favourites', 'encrypt_content', 'show_encrypted' ] widgets = { 'author_id': forms.HiddenInput(), 'tweet_id': forms.HiddenInput(), 'encrypted_content': forms.HiddenInput(), 'replies': forms.HiddenInput(), 'favourites': forms.HiddenInput(), 'content': forms.Textarea(attrs={'onkeypress': Emoji.names()}), 'show_encrypted': forms.HiddenInput() }
def emoji_replace_html_entities(value): return mark_safe(Emoji.replace_html_entities(value))
def emoji(arg=None): from emoji import Emoji if arg in Emoji.keys(): return mark_safe(Emoji.replace(':' + arg + ':')) else: return ''
def emoji_replace_unicode(value): return mark_safe(Emoji.replace_unicode(value))
def testValidEmoji(self): emoji = Emoji() self.assertEqual( emoji.replace(':neckbeard:'), '<img class="emoji" title="neckbeard" alt="neckbeard" height="20" width="20" src="https://assets-cdn.github.com/images/icons/emoji/neckbeard.png?v5" align="top">' )
if row < QUEENS: for i in range(QUEENS): if position_is_free(row, i): position_mark_used(row, i) # Try the next row place_a_queen(row + 1) position_mark_free(row, i) else: solvcount = solvcount + 1 solved.setText(str(solvcount)) speaker.tone(1800, 50) wait(1) # Init screen setScreenColor(0x222222) solved = M5TextBox(5, 6, "0", lcd.FONT_DejaVu40, 0xddf606, rotate=0) hor = None diag = None solvcount = 0 diag2 = None QUEENS = 8 # Place 8 queens on the chess board, show all solutions # See: https://en.wikipedia.org/wiki/Eight_queens_puzzle emoji0 = Emoji(QUEENS, QUEENS, 15, 9) position_mark_all_clear() solvcount = 0 place_a_queen(0)
def save(self, *arg, **kwargs): self.content = Emoji.replace(self.content) self.title = Emoji.replace(self.title) super(SideBar, self).save(*arg, **kwargs)
def save(self, *arg, **kwargs): self.slug = slugify(self.title) self.content = Emoji.replace(self.content) self.title = Emoji.replace(self.title) super(Post, self).save(*arg, **kwargs)
* code_point ("code_points":{"output": ".."} in emoji.json) * name * category * shortname * shortname_alternates * ascii * keywords ''' for id, key in enumerate(emojis_json): if key.lstrip("0") in blacklist: continue emoji_json = emojis_json[key] emoji = Emoji() # sets real_code (this is used when "removes some emoji") emoji.real_code = key # sets id emoji.id = id # sets code field = key.lstrip("0") emoji.code = field emoji.keywords.add(field) # sets code_point field = emoji_json["code_points"]["output"] emoji.code_point = field
def testInvalidEmoji(self): emoji = Emoji() invalid = ':neckbeard2:' self.assertEqual(emoji.replace(invalid), invalid)
def testEmojiWithEmpty(self): emoji = Emoji() self.assertEqual(emoji.replace(''), '') self.assertEqual(emoji.replace(None), None)
""" Launches GifSicle conversion process queue filled with add() method """ self.tp.launch_list() self.tp = None def lossy(input_file, lossy_factor, color_map, delay=3, output_file=None): if output_file is None: output_file = input_file if __name__ == '__main__': GifSicle(Emoji( r'C:\Python\Vault_Of_Gifs\input\Marshawn_Lynch_Emoji-01-280x280-30FPS.gif' ), 100, r"C:\Python\Vault_Of_Gifs\input\_Marshall_Lynch_Emoji_01.act", to_damaged=True) # gc = GifSicle() # gc.add(r'C:\Python\Vault_Of_Gifs\input\Emoji-02-280x280-30FPS.gif', # 200, # r"C:\Python\Vault_Of_Gifs\act\xxx.act", # output_file=r'C:\Python\Vault_Of_Gifs\input\Emoji-02-280x280-30FPS-lossy.gif') # gc.add(r'C:\Python\Vault_Of_Gifs\input\Marshawn_Lynch_Emoji-01-280x280-30FPS.gif', # 200, # r"C:\Python\Vault_Of_Gifs\act\perc.act", # output_file=r'C:\Python\Vault_Of_Gifs\input\Marshawn_Lynch_Emoji-01-280x280-30FPS-lossy.gif') # gc.run() pass
def __init__(self, user, message): self.user = str(user) self.message = message # Each of the unique Discord ids for the users self.users = { # @UnitZer0 '211258171094859776': Emoji([], []), # @tjx1212 '214581352689958922': Emoji(['🦀'], ['TJ is a crustacean']), # @naps '180729155829104640': Emoji(['🐒'], ['Return to monke']), # @ZaqueXIII '153673650929664000': Emoji([], []), # @Blitztraum '196317961890299904': Emoji([], []), # @Coop '214861395211059201': Emoji([], []), # @JorJor The Dinosaur '205043049024323584': Emoji(['💧'], ['¯\_(ツ)_/¯']), # @Roost '181914855706460160': Emoji([], []), # @Zega(Tyler) '272442562177007619': Emoji([], []), # @Blahman '220341843315916800': Emoji([], []), # @GaryArk3443 '388449127333232642': Emoji([], []), # @A Single Neuron '187039157426585600': Emoji([], []), # @lucii '424766351622537216': Emoji([], []) } year = date.today().year # Emoji for each of the different days (Format MM-DD) self.days = { # New years Day '01-01': Emoji(['🎉'], [f'New Year\'s Day ({year}-01-01)']), # Valentines Day '02-14': Emoji(['💘', '🌵'], [ f'Valentine\'s Day ({year}-02-14)', f'Ariziona\'s {year - 1912} Birthday ({year}-02-14)' ]), '03-14': Emoji(['🥧'], [ '3.14159265358979323846264338327950288419716939937510582097494459230781640' ]), '04-02': Emoji(['🌈', '🐈'], [ 'Nyan Cat 10 Years', 'https://www.youtube.com/watch?v=QH2-TGUlwu4' ]), # 4th of July '07-04': Emoji(['🇺🇸'], [ f'America\'s {date.today().year - 1776} Birthday ({year}-07-04)' ]), # Thanksgiving '11-26': Emoji(['🦃'], [f'Thanksgiving (US) ({year}-11-25)']), # Hanukkah 2020 Dates '12-10': Emoji(['🕎'], [f'Hanukkah ({year}-11-28 to {year}-12-06)']), # X-Mass '12-25': Emoji(['🎄'], [f'Christmas Day ({year}-12-25)']), # Boxing day '12-26': Emoji(['📦'], [f'Boxing Day ({year}-12-26)']), # New Years Eve '12-31': Emoji(['🎉'], [f'New Year\'s Eve ({year}-12-31)']) } self.message_emojis = { 'games': Emoji(['🎮'], ['You asked to play games']), 'pen15': Emoji(['🍆'], [ 'Your message contained \'pen\' and numbers that summed to 15' ]) }
def do_markdown_emoji(text): if not text: return "" emoji_text = Emoji.replace(text) return mark_safe(make_markdown(emoji_text))
def emoji_replace_unicode(value, autoescape=None): autoescape = autoescape and not isinstance(value, SafeData) if autoescape: value = escape(value) return mark_safe(Emoji.replace_unicode(value))