@@ -95,19 +95,18 @@ def _write_text(self, text):
9595 f .write (text )
9696 Path .write_text = _write_text
9797
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 )
109108
110- Path .mkdir = _mkdir
109+ Path .mkdir = _mkdir
111110
112111
113112def split_filename (fname ):
@@ -828,7 +827,7 @@ def dist_is_editable(dist):
828827 return False
829828
830829
831- def makedirs (path , exist_ok = False ):
830+ def makedirs (path , mode = 0o777 , exist_ok = False ):
832831 """
833832 Create path, if it doesn't exist.
834833
@@ -838,14 +837,14 @@ def makedirs(path, exist_ok=False):
838837
839838 """
840839 if not exist_ok : # The old makedirs
841- os .makedirs (path )
840+ os .makedirs (path , mode = mode )
842841 return path
843842
844843 # this odd approach deals with concurrent directory cureation
845844 if not op .exists (op .abspath (path )):
846845 fmlogger .debug ("Creating directory %s" , path )
847846 try :
848- os .makedirs (path )
847+ os .makedirs (path , mode = mode )
849848 except OSError :
850849 fmlogger .debug ("Problem creating directory %s" , path )
851850 if not op .exists (path ):
0 commit comments