3 #-----------------------------------------------------------------------------
4 # Borrowed initially from https://github.com/mrowa44/emojify
5 # Copyright (c) 2015 Justyna Rachowicz
6 # Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # See LICENSE.txt for the text of the license.
19 #-----------------------------------------------------------------------------
21 from urllib
.request
import urlopen
25 EMOJI_JSON_URL
= 'https://raw.githubusercontent.com/github/gemoji/master/db/emoji.json'
27 def string_emoji(emoji_json
):
28 for alias
in emoji_json
['aliases']:
29 return(' {{":{0}:", "{1}"}}, // {2}\n'.format(alias
,
30 ''.join('\\x{:02x}'.format(b
) for b
in emoji_json
['emoji'].encode('utf8')),
33 C_HEADER
="""//-----------------------------------------------------------------------------
34 // Borrowed initially from https://github.com/github/gemoji
35 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
37 // This program is free software: you can redistribute it and/or modify
38 // it under the terms of the GNU General Public License as published by
39 // the Free Software Foundation, either version 3 of the License, or
40 // (at your option) any later version.
42 // This program is distributed in the hope that it will be useful,
43 // but WITHOUT ANY WARRANTY; without even the implied warranty of
44 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 // GNU General Public License for more details.
47 // See LICENSE.txt for the text of the license.
48 //-----------------------------------------------------------------------------
49 // *DO NOT EDIT MANUALLY*
50 // Autogenerated with emojis_scrap_github.py
51 //-----------------------------------------------------------------------------
55 typedef struct emoji_s {
59 // emoji_t array are expected to be NULL terminated
61 static emoji_t EmojiTable[] = {
64 C_FOOTER
=""" {NULL, NULL}
69 with
open('src/emojis.h','w') as femoji
:
70 with
urlopen(EMOJI_JSON_URL
) as conn
:
71 emojis_json
= json
.loads(conn
.read().decode('utf-8'))
72 femoji
.write(C_HEADER
)
73 for emoji_json
in emojis_json
:
74 femoji
.write(string_emoji(emoji_json
))
75 femoji
.write(C_FOOTER
)