From fa8088a3ebb23c7ea1d3a673a4fc638fd043ff24 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 15 Dec 2014 18:49:43 +0530 Subject: [PATCH] More refined code --- ee/core/download.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ee/core/download.py b/ee/core/download.py index 0f2f45ab..f8bea58b 100644 --- a/ee/core/download.py +++ b/ee/core/download.py @@ -1,6 +1,7 @@ """EasyEngine download core classes.""" import urllib.request import urllib.error +import os class EEDownload(): @@ -10,6 +11,9 @@ class EEDownload(): def download(url, filename): try: + directory = os.path.dirname(filename) + if not os.path.exists(directory): + os.makedirs(directory) urllib.request.urlretrieve(url, filename) return True except urllib.error.URLError as e: