mirror of https://github.com/zulip/zulip.git
build_emoji: Extract `generate_map_files()` function.
This commit extracts out the `generate_map_files()` function from the `dump_emojis()` function. This function generates various data files like `emoji_codes.js`, `name_to_codepoint.json` etc which are used by webapp, bugdown etc.
This commit is contained in:
parent
ef96adf7e5
commit
e295bed20f
|
@ -290,25 +290,9 @@ def setup_old_emoji_farm(cache_path, emoji_map):
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def dump_emojis(cache_path):
|
def generate_map_files(cache_path, emoji_map, emoji_data, emoji_catalog, unified_reactions_data):
|
||||||
# type: (str) -> None
|
# type: (Text, Dict[Text, Text], List[Dict[Text, Any]], Dict[Text, List[Text]], Dict[Text, Text]) -> None
|
||||||
with open('emoji_map.json') as emoji_map_file:
|
# This function generates the various data files consumed by webapp, mobile apps, bugdown etc.
|
||||||
emoji_map = ujson.load(emoji_map_file)
|
|
||||||
|
|
||||||
EMOJI_DATA_FILE_PATH = os.path.join(EMOJI_DATA_PATH, 'emoji.json')
|
|
||||||
with open(EMOJI_DATA_FILE_PATH) as emoji_data_file:
|
|
||||||
emoji_data = ujson.load(emoji_data_file)
|
|
||||||
emoji_catalog = generate_emoji_catalog(emoji_data)
|
|
||||||
|
|
||||||
UNIFIED_REACTIONS_PATH = os.path.join(ZULIP_PATH, 'zerver', 'management', 'data', 'unified_reactions.json')
|
|
||||||
with open(UNIFIED_REACTIONS_PATH) as unified_reactions_file:
|
|
||||||
unified_reactions_data = ujson.load(unified_reactions_file)
|
|
||||||
|
|
||||||
# Setup emoji farms.
|
|
||||||
run(['rm', '-rf', cache_path])
|
|
||||||
setup_emoji_farm(cache_path, emoji_map, emoji_data)
|
|
||||||
setup_old_emoji_farm(cache_path, emoji_map)
|
|
||||||
|
|
||||||
EMOJI_CODES_PATH = os.path.join(cache_path, 'emoji_codes.js')
|
EMOJI_CODES_PATH = os.path.join(cache_path, 'emoji_codes.js')
|
||||||
emoji_codes_file = open(EMOJI_CODES_PATH, 'w')
|
emoji_codes_file = open(EMOJI_CODES_PATH, 'w')
|
||||||
|
|
||||||
|
@ -350,5 +334,27 @@ def dump_emojis(cache_path):
|
||||||
codepoint_to_name_file.write(ujson.dumps(codepoint_to_name))
|
codepoint_to_name_file.write(ujson.dumps(codepoint_to_name))
|
||||||
codepoint_to_name_file.close()
|
codepoint_to_name_file.close()
|
||||||
|
|
||||||
|
def dump_emojis(cache_path):
|
||||||
|
# type: (str) -> None
|
||||||
|
with open('emoji_map.json') as emoji_map_file:
|
||||||
|
emoji_map = ujson.load(emoji_map_file)
|
||||||
|
|
||||||
|
EMOJI_DATA_FILE_PATH = os.path.join(EMOJI_DATA_PATH, 'emoji.json')
|
||||||
|
with open(EMOJI_DATA_FILE_PATH) as emoji_data_file:
|
||||||
|
emoji_data = ujson.load(emoji_data_file)
|
||||||
|
emoji_catalog = generate_emoji_catalog(emoji_data)
|
||||||
|
|
||||||
|
UNIFIED_REACTIONS_PATH = os.path.join(ZULIP_PATH, 'zerver', 'management', 'data', 'unified_reactions.json')
|
||||||
|
with open(UNIFIED_REACTIONS_PATH) as unified_reactions_file:
|
||||||
|
unified_reactions_data = ujson.load(unified_reactions_file)
|
||||||
|
|
||||||
|
# Setup emoji farms.
|
||||||
|
run(['rm', '-rf', cache_path])
|
||||||
|
setup_emoji_farm(cache_path, emoji_map, emoji_data)
|
||||||
|
setup_old_emoji_farm(cache_path, emoji_map)
|
||||||
|
|
||||||
|
# Generate various map files.
|
||||||
|
generate_map_files(cache_path, emoji_map, emoji_data, emoji_catalog, unified_reactions_data)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue