From a876ebb52a7d38d30003d56911e97786e844db0d Mon Sep 17 00:00:00 2001 From: Harshit Bansal Date: Thu, 29 Jun 2017 21:22:29 +0000 Subject: [PATCH] build_emoji: Close open file objects after reading. --- tools/setup/emoji/build_emoji | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/setup/emoji/build_emoji b/tools/setup/emoji/build_emoji index 1a8289d675..f63344054d 100755 --- a/tools/setup/emoji/build_emoji +++ b/tools/setup/emoji/build_emoji @@ -202,9 +202,14 @@ def dump_emojis(cache_path): # type: (str) -> None subprocess.call('ttx -v -z extfile -d {} NotoColorEmoji.ttf'.format(EMOJI_DUMP_DIR_PATH), shell=True) - emoji_map = ujson.load(open('emoji_map.json')) + with open('emoji_map.json') as emoji_map_file: + emoji_map = ujson.load(emoji_map_file) + code_point_to_fname_map = code_point_to_file_name_map(EMOJI_DUMP_PATH("NotoColorEmoji.ttx")) - emoji_data = ujson.load(open(os.path.join(EMOJI_DATA_PATH, 'emoji.json'))) + + 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')