@@ -197,22 +197,28 @@ def _add(str, fn):
197197# Super directory utilities.
198198# (Inspired by Eric Raymond; the doc strings are mostly his)
199199
200- def makedirs (name , mode = 0o777 , exist_ok = False ):
201- """makedirs(name [, mode=0o777][, exist_ok=False])
200+ def makedirs (name , mode = 0o777 , exist_ok = False , * , recursive_mode = False ):
201+ """makedirs(name [, mode=0o777][, exist_ok=False][, recursive_mode=False] )
202202
203203 Super-mkdir; create a leaf directory and all intermediate ones. Works like
204204 mkdir, except that any intermediate path segment (not just the rightmost)
205205 will be created if it does not exist. If the target directory already
206206 exists, raise an OSError if exist_ok is False. Otherwise no exception is
207- raised. This is recursive.
207+ raised. If recursive_mode is True, the mode argument will affect the file
208+ permission bits of any newly-created, intermediate-level directories. This
209+ is recursive.
208210
209211 """
210212 head , tail = path .split (name )
211213 if not tail :
212214 head , tail = path .split (head )
213215 if head and tail and not path .exists (head ):
214216 try :
215- makedirs (head , exist_ok = exist_ok )
217+ if recursive_mode :
218+ makedirs (head , mode = mode , exist_ok = exist_ok ,
219+ recursive_mode = True )
220+ else :
221+ makedirs (head , exist_ok = exist_ok )
216222 except FileExistsError :
217223 # Defeats race condition when another thread created the path
218224 pass
0 commit comments