8 examples of 'python mkdir recursive' in Python

Every line of 'python mkdir recursive' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
74def recursiveCreateDir(dir):
75 o.debug("Creating destination {}".format(dir))
76 if not config.testMode:
77 if not os.path.exists(dir):
78 try:
79 os.makedirs(dir)
80 except OSError as e:
81 if e.errno != errno.EEXIST:
82 o.error('Unable to create {}'.format(dir))
248def mkdir(path: AnyStr, mode: int = 0o777) -> None: pass
424def mkdir(path,root=None,mode=None):
425 '''create a new directory in the root directory
426
427 create a directory at *path* and any necessary parents (i.e. ``mkdir -p``).
428 Default mode is read/write/execute for \'user\' and \'group\', and then
429 read/execute otherwise.
430
431 Args:
432 path (str): string name of the new directory.
433 root (str, default=None): path at which to build the new directory.
434 mode (str, default=None): octal read/write permission [default: 0o775].
435
436 Returns:
437 string absolute path for new directory.
438 '''
439 if mode is None: mode = MODE
440 if not root: root = os.curdir
441 newdir = os.path.join(root,path)
442 absdir = os.path.abspath(newdir)
443 import errno
444 try:
445 os.makedirs(absdir,mode)
446 return absdir
447 except OSError:
448 err = sys.exc_info()[0]
449 if (err.errno != errno.EEXIST) or (not os.path.isdir(absdir)):
450 raise
146def mkdirs(*args: Path) -> None:
147 for dir in args:
148 dir.mkdir(parents=True, exist_ok=True)
39def mkdir(*args, **kwargs):
40 """
41 Create the specified directory.
42 Tolerant of race conditions.
43
44 :param args: path[, mode] that goes to os.makedirs
45 :param kwargs: path
46 :return:
47 """
48 try:
49 os.makedirs(*args, **kwargs)
50 except OSError, e:
51 if e.errno != errno.EEXIST:
52 raise
105def makedirs(name, mode=511):
106 head, tail = path.split(name)
107 if not tail:
108 head, tail = path.split(head)
109 if head and tail and not path.exists(head):
110 try:
111 makedirs(head, mode)
112 except OSError as e:
113 if e.errno != errno.EEXIST:
114 raise
115
116 if tail == curdir:
117 return
118 mkdir(name, mode)
41def mkdir(path):
42 try:
43 os.makedirs(path)
44 return True
45 except OSError:
46 return False
50def mkdirP(d):
51 try:
52 os.makedirs(d)
53 except OSError, err:
54 if err.errno != errno.EEXIST:
55 raise

Related snippets