File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 10
10
import os
11
11
import errno
12
12
import logging
13
+ import sys
13
14
try :
14
15
from pathlib import Path # Built-in in Python 3
15
16
except :
28
29
def _mkdir_p (path ):
29
30
"""Creates a directory, and any necessary parents.
30
31
31
- This implementation based on a Stack Overflow question that can be found here:
32
- https://stackoverflow.com/questions/600268/mkdir-p-functionality-in-python
33
-
34
32
If the path provided is an existing file, this function raises an exception.
35
33
:param path: The directory name that should be created.
36
34
"""
37
35
if not path :
38
36
return # NO-OP
37
+
38
+ if sys .version_info >= (3 , 2 ):
39
+ os .makedirs (path , exist_ok = True )
40
+ return
41
+
42
+ # This fallback implementation is based on a Stack Overflow question:
43
+ # https://stackoverflow.com/questions/600268/mkdir-p-functionality-in-python
44
+ # Known issue: it won't work when the path is a root folder like "C:\\"
39
45
try :
40
46
os .makedirs (path )
41
47
except OSError as exp :
You can’t perform that action at this time.
0 commit comments