From 23c5b6f82bc51712b4d9d19f0edbcc621b395d83 Mon Sep 17 00:00:00 2001 From: Christoph Date: Tue, 18 Jul 2017 14:32:03 -0400 Subject: [PATCH] Added creation of downloads dir if it doesn't exist for chapter17 flags. --- 17-futures/countries/flags.py | 2 ++ 17-futures/countries/flags2_common.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/17-futures/countries/flags.py b/17-futures/countries/flags.py index 7731bc4..d9f5f94 100644 --- a/17-futures/countries/flags.py +++ b/17-futures/countries/flags.py @@ -25,6 +25,8 @@ def save_flag(img, filename): # <5> + if not os.path.exists(DEST_DIR): + os.makedirs(DEST_DIR) path = os.path.join(DEST_DIR, filename) with open(path, 'wb') as fp: fp.write(img) diff --git a/17-futures/countries/flags2_common.py b/17-futures/countries/flags2_common.py index bfa40fb..9586795 100644 --- a/17-futures/countries/flags2_common.py +++ b/17-futures/countries/flags2_common.py @@ -33,6 +33,8 @@ def save_flag(img, filename): + if not os.path.exists(DEST_DIR): + os.makedirs(DEST_DIR) path = os.path.join(DEST_DIR, filename) with open(path, 'wb') as fp: fp.write(img)