Commit 6e763559 authored by Kyle Anderson's avatar Kyle Anderson

Add check for directory existence

Added a check to ensure the directory that we're about to attempt to write to exists, and if it doesn't it creates the full tree.
parent 8e74019a
......@@ -2,6 +2,7 @@
General IO for pickle database operations.
"""
import os
import pickle
......@@ -49,5 +50,8 @@ def write_database(output_file: str, database_content) -> None:
:return: None
"""
if output_file and database_content and database_content is not None:
directory: str = os.path.dirname(output_file)
if not os.path.isdir(directory):
os.makedirs(directory)
with open(output_file, "wb") as output:
pickle.dump(database_content, output)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment