Create missing intermediate directories.

This commit is contained in:
Julien Palard 2017-04-29 11:23:04 +02:00
parent f202b3762c
commit df110ef0e2
1 changed files with 3 additions and 2 deletions

View File

@ -6,8 +6,8 @@ differs, showing him diffs.
from filecmp import cmpfiles
from difflib import unified_diff
from os.path import expanduser, join, isdir, exists
from os import listdir
from os.path import expanduser, join, isdir, exists, dirname
from os import listdir, makedirs
from shutil import copy2 as copy
from itertools import chain
@ -15,6 +15,7 @@ from itertools import chain
def maybe_copy_file(src, dest):
if not exists(dest):
if input("Copy {} [y,n]? ".format(src)).lower()[0] == 'y':
makedirs(dirname(dest), exist_ok=True)
copy(src, dest)
return
with open(src) as a, open(dest) as b: