From 73ab9aac53aa37ecefd54614bdd008c8dcb23bb5 Mon Sep 17 00:00:00 2001 From: Raagul N Date: Wed, 13 Mar 2024 16:56:48 -0700 Subject: [PATCH 1/2] updating write logic for get_metadata.py --- scripts/get_metadata.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/get_metadata.py b/scripts/get_metadata.py index 0b3a85e..4c0804a 100644 --- a/scripts/get_metadata.py +++ b/scripts/get_metadata.py @@ -75,9 +75,9 @@ def write_show_metadata(output_file, dict_data): raise ValueError("Provide dict_data parameter!") if len(dict_data.keys()) == 0: raise ValueError('Provide a valid dictionary data to write to the output file!') - with open(output_file, 'w', encoding="utf-8") as (outfile, error): - if error: - raise IOError(error) + with open(output_file, 'r+', encoding="utf-8") as outfile: + # if error: + # raise IOError(error) json.dump(dict_data, outfile, sort_keys=True, indent=2) def _format_episode_metadata(episode_metadata): @@ -158,6 +158,6 @@ def write_episode_metadata(output_file, episodes_data): if __name__ == "__main__": data = get_show_metadata(IMDB_GOT_ID) - write_show_metadata('./thronetalk-game-of-thrones-summarizer/data/show_metadata.json', data) + write_show_metadata('thronetalk-game-of-thrones-summarizer/data/show_metadata.json', data) episodes_metadata = get_episode_metadata() - write_episode_metadata('./thronetalk-game-of-thrones-summarizer/data/episodes_metadata.csv', episodes_metadata) + write_episode_metadata('thronetalk-game-of-thrones-summarizer/data/episodes_metadata.csv', episodes_metadata) From cc2b42b3060b96cb4b99bee5103bb26c88cee5ab Mon Sep 17 00:00:00 2001 From: Raagul N Date: Wed, 13 Mar 2024 16:58:04 -0700 Subject: [PATCH 2/2] remove comments --- scripts/get_metadata.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/get_metadata.py b/scripts/get_metadata.py index 4c0804a..ba975d2 100644 --- a/scripts/get_metadata.py +++ b/scripts/get_metadata.py @@ -76,8 +76,6 @@ def write_show_metadata(output_file, dict_data): if len(dict_data.keys()) == 0: raise ValueError('Provide a valid dictionary data to write to the output file!') with open(output_file, 'r+', encoding="utf-8") as outfile: - # if error: - # raise IOError(error) json.dump(dict_data, outfile, sort_keys=True, indent=2) def _format_episode_metadata(episode_metadata):