From 07101231d9aeeaa8d593218cd856945e91e73e31 Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Thu, 16 Jun 2016 06:29:04 -0500 Subject: [PATCH] Ensure that the directories exist If we create our temporary directory structure for our files, we need to ensure that all the directories (including the ones in the filename) exist before we copy the contents to that location. --- flake8/main/git.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flake8/main/git.py b/flake8/main/git.py index c9b7dad..39c2ad1 100644 --- a/flake8/main/git.py +++ b/flake8/main/git.py @@ -116,6 +116,8 @@ def copy_file_to(destination_directory, filepath, contents): directory, filename = os.path.split(os.path.abspath(filepath)) temporary_directory = make_temporary_directory_from(destination_directory, directory) + if not os.path.exists(temporary_directory): + os.makedirs(temporary_directory) temporary_filepath = os.path.join(temporary_directory, filename) with open(temporary_filepath, 'wb') as fd: fd.write(contents)