@@ -95,19 +95,18 @@ def _write_text(self, text):
95
95
f .write (text )
96
96
Path .write_text = _write_text
97
97
98
- if PY3 :
99
- try : # PY34 - mkdir does not have exist_ok
100
- from tempfile import TemporaryDirectory
101
- with TemporaryDirectory () as tmpdir :
102
- (Path (tmpdir ) / 'exist_ok_test' ).mkdir (exist_ok = True )
103
- except TypeError :
104
- def _mkdir (self , mode = 0o777 , parents = False , exist_ok = False ):
105
- if parents :
106
- os .makedirs (str (self ), mode = mode , exist_ok = exist_ok )
107
- elif not exist_ok or not self .exists ():
108
- os .mkdir (str (self ), mode = mode )
98
+ try : # PY27/PY34 - mkdir does not have exist_ok
99
+ from .tmpdirs import TemporaryDirectory
100
+ with TemporaryDirectory () as tmpdir :
101
+ (Path (tmpdir ) / 'exist_ok_test' ).mkdir (exist_ok = True )
102
+ except TypeError :
103
+ def _mkdir (self , mode = 0o777 , parents = False , exist_ok = False ):
104
+ if parents :
105
+ makedirs (str (self ), mode = mode , exist_ok = exist_ok )
106
+ elif not exist_ok or not self .exists ():
107
+ os .mkdir (str (self ), mode = mode )
109
108
110
- Path .mkdir = _mkdir
109
+ Path .mkdir = _mkdir
111
110
112
111
113
112
def split_filename (fname ):
@@ -828,7 +827,7 @@ def dist_is_editable(dist):
828
827
return False
829
828
830
829
831
- def makedirs (path , exist_ok = False ):
830
+ def makedirs (path , mode = 0o777 , exist_ok = False ):
832
831
"""
833
832
Create path, if it doesn't exist.
834
833
@@ -838,14 +837,14 @@ def makedirs(path, exist_ok=False):
838
837
839
838
"""
840
839
if not exist_ok : # The old makedirs
841
- os .makedirs (path )
840
+ os .makedirs (path , mode = mode )
842
841
return path
843
842
844
843
# this odd approach deals with concurrent directory cureation
845
844
if not op .exists (op .abspath (path )):
846
845
fmlogger .debug ("Creating directory %s" , path )
847
846
try :
848
- os .makedirs (path )
847
+ os .makedirs (path , mode = mode )
849
848
except OSError :
850
849
fmlogger .debug ("Problem creating directory %s" , path )
851
850
if not op .exists (path ):
0 commit comments