MCPcopy Index your code
hub / github.com/RustPython/RustPython / makedirs

Function makedirs

Lib/os.py:211–241  ·  view source on GitHub ↗

makedirs(name [, mode=0o777][, exist_ok=False]) Super-mkdir; create a leaf directory and all intermediate ones. Works like mkdir, except that any intermediate path segment (not just the rightmost) will be created if it does not exist. If the target directory already exists, raise a

(name, mode=0o777, exist_ok=False)

Source from the content-addressed store, hash-verified

209# (Inspired by Eric Raymond; the doc strings are mostly his)
210
211def makedirs(name, mode=0o777, exist_ok=False):
212 """makedirs(name [, mode=0o777][, exist_ok=False])
213
214 Super-mkdir; create a leaf directory and all intermediate ones. Works like
215 mkdir, except that any intermediate path segment (not just the rightmost)
216 will be created if it does not exist. If the target directory already
217 exists, raise an OSError if exist_ok is False. Otherwise no exception is
218 raised. This is recursive.
219
220 """
221 head, tail = path.split(name)
222 if not tail:
223 head, tail = path.split(head)
224 if head and tail and not path.exists(head):
225 try:
226 makedirs(head, exist_ok=exist_ok)
227 except FileExistsError:
228 # Defeats race condition when another thread created the path
229 pass
230 cdir = curdir
231 if isinstance(tail, bytes):
232 cdir = bytes(curdir, 'ASCII')
233 if tail == cdir: # xxx/newdir/. exists if xxx/newdir exists
234 return
235 try:
236 mkdir(name, mode)
237 except OSError:
238 # Cannot rely on checking for EEXIST, since the operating system
239 # could give priority to other errors like EACCES or EROFS
240 if not exist_ok or not path.isdir(name):
241 raise
242
243def removedirs(name):
244 """removedirs(name)

Callers 1

renamesFunction · 0.85

Calls 5

isinstanceFunction · 0.85
mkdirFunction · 0.50
splitMethod · 0.45
existsMethod · 0.45
isdirMethod · 0.45

Tested by

no test coverage detected