MCPcopy Index your code
hub / github.com/ipython/ipython / ensure_dir_exists

Function ensure_dir_exists

IPython/utils/path.py:339–354  ·  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: str, mode: int=0o755)

Source from the content-addressed store, hash-verified

337 shutil.copy(src, dst)
338
339def ensure_dir_exists(path: str, mode: int=0o755):
340 """ensure that a directory exists
341
342 If it doesn't exist, try to create it and protect against a race condition
343 if another process is doing the same.
344
345 The default permissions are 755, which differ from os.makedirs default of 777.
346 """
347 if not os.path.exists(path):
348 try:
349 os.makedirs(path, mode=mode)
350 except OSError as e:
351 if e.errno != errno.EEXIST:
352 raise
353 elif not os.path.isdir(path):
354 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
completionsMethod · 0.90
_location_changedMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…