Script to create a Mac dictionary file

Suggestion in markdown format of emoji that can be used on github? A shit-like script that creates a dictionary file If you import the created file in the settings and convert it with "Eji", you will get an emoji that can be used on github like: hoge :.

http://www.emoji-cheat-sheet.com I'm bringing an emoji from.

create_emoji_dictionary.sh

#!/bin/sh
EMOJI_DIR=/tmp/emoji_`date +"%Y%m%d_%H%M%S"`
mkdir -p $EMOJI_DIR
python emoji_to_dic.py > $EMOJI_DIR/mardkdown_utf8.txt
iconv -f utf-8 -t utf-16 $EMOJI_DIR/mardkdown_utf8.txt > $EMOJI_DIR/mardkdown.txt
open $EMOJI_DIR

emoji_to_dic.py

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import codecs
import sys
import urllib
from HTMLParser import HTMLParser

'''
Fixed variables
'''
url = 'http://www.emoji-cheat-sheet.com/'

'''
Parser
'''
class EmojiParser(HTMLParser):
  def __init__(self):
    HTMLParser.__init__(self)
    self.isToken = False
    self.token = ''

    '''
    ' Find software version tag.
    '''
  def handle_starttag(self, tag, attrs):
    self.isToken = False 
    attrs = dict(attrs)
    if tag != 'span':
      return
    if 'class' not in attrs:
      return
    if attrs['class'] != 'name':
      return
    self.isToken = True

  '''
  ' Extraction version data.
  '''
  def handle_data(self, data):
    data = data.strip('\ \n:')
    if not self.isToken:
      return
    if not data:
      return
    print u'"Eji",":' + data + u':","Appellative"'

def GetParser():
  return EmojiParser()

'''
Main.
'''
if __name__ == "__main__":
  parser = GetParser()
  if not parser:
    print 'none parser.'
    sys.exit(1)
  sys.stdout = codecs.getwriter('utf_8')(sys.stdout)
  parser.feed(urllib.urlopen(url).read())

Recommended Posts

Script to create a Mac dictionary file
Python script to create a JSON file from a CSV file
How to create a config file
Various ways to create a dictionary (memories)
Create a shell script to run the python file multiple times
How to create a JSON file in Python
[Note] How to create a Mac development environment
Create a dictionary in Python
Upload a file to Dropbox
A memorandum to run a python script in a bat file
Create a dummy data file
How to create a simple TCP server / client script
How to use NUITKA-Utilities hinted-compilation to easily create an executable file from a Python script
A Python script that saves a clipboard (GTK) image to a file.
Steps to create a Django project
Create a Python environment on Mac (2017/4)
Create a nested dictionary using defaultdict
How to create a Conda package
Write standard output to a file
Create a binary file in Python
How to create a virtual bridge
How to create a Dockerfile (basic)
Metaclass (wip) to generate a dictionary
5 Ways to Create a Python Chatbot
Create a file uploader with Django
Conditional branch due to the existence of a shell script file
Python vba to create a date string for creating a file name
How to create a CSV dummy file containing Japanese using Faker
I tried to create a linebot (implementation)
How to create a clone from Github
Create a bot to retweet coronavirus information
How to create a git clone folder
I tried to create a linebot (preparation)
Script to generate directory from json file
Execute a script from Jupyter to process
Create a python environment on your Mac
Create a large text file with shellscript
A simple IDAPython script to name a function
Create a star system with Blender 2.80 script
Create a VM with a YAML file (KVM)
I made a script to display emoji
Create a deb file from a python package
[GPS] Create a kml file in Python
Creating a shell script to write a diary
How to run a Maya Python script
Create a shortcut to run a Python file in VScode on your terminal
What is the fastest way to create a reverse dictionary in python?
[Python] List Comprehension Various ways to create a list
Script python file
How to read a CSV file with Python 2/3
I made a python dictionary file for Neocomplete
Create a GIF file using Pillow in Python
I want to easily create a Noise Model
How to create a Python virtual environment (venv)
How to create a function object from a string
Create a GUI executable file created with tkinter
Create an executable file in a scripting language
I want to create a window in Python
Randomly sample MNIST data to create a dataset
How to make a dictionary with a hierarchical structure.
Script to create FlatBuffers binaries from SQL database