MCPcopy Create free account
hub / github.com/ipython/ipython / ensure_dir_exists

Function ensure_dir_exists

IPython/utils/path.py:421–436  ·  view source on GitHub ↗

ensure that a directory exists If it doesn't exist, try to create it and protect against a race condition if another process is doing the same. The default permissions are 755, which differ from os.makedirs default of 777.

(path, mode=0o755)

Source from the content-addressed store, hash-verified

419 shutil.copy(src, dst)
420
421def ensure_dir_exists(path, mode=0o755):
422 """ensure that a directory exists
423
424 If it doesn't exist, try to create it and protect against a race condition
425 if another process is doing the same.
426
427 The default permissions are 755, which differ from os.makedirs default of 777.
428 """
429 if not os.path.exists(path):
430 try:
431 os.makedirs(path, mode=mode)
432 except OSError as e:
433 if e.errno != errno.EEXIST:
434 raise
435 elif not os.path.isdir(path):
436 raise IOError("%r exists but is not a directory" % path)

Callers 5

get_ipython_cache_dirFunction · 0.90
_ipython_dir_changedMethod · 0.90
_ipython_dir_changedMethod · 0.90
_location_changedMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected