style
[RRG-proxmark3.git] / client / emojis_scrap_github.py
blob330e40c21061baec517ee05ffd729e5d09fc297a
1 #!/usr/bin/env python3
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
22 import json
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')),
31 emoji_json['emoji']))
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 //-----------------------------------------------------------------------------
52 #ifndef EMOJIS_H__
53 #define EMOJIS_H__
55 typedef struct emoji_s {
56 const char *alias;
57 const char *emoji;
58 } emoji_t;
59 // emoji_t array are expected to be NULL terminated
61 static emoji_t EmojiTable[] = {
62 """
64 C_FOOTER=""" {NULL, NULL}
66 #endif
67 """
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)