10 examples of 'pathlib make directory' in Python

Every line of 'pathlib make directory' 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
this disclaimer
33def make(folder):
34 if not os.path.exists(folder):
35 os.makedirs(folder)
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

5def makepath(path):
6 if not isdir(path):
7 makedirs(path)
35def make_dirs(*lpath):
36 """Ensure the directories exist.
37
38 lpath: list of directories
39 """
40 path = os.path.join(*lpath)
41 try:
42 os.makedirs(os.path.dirname(path))
43 except OSError as e:
44 if e.errno != errno.EEXIST:
45 raise
46 return os.path.abspath(path)
9def create_dir(name):
10 if not Path.exists(name):
11 Path.mkdir(name)
5def make_dir_nx(p: str):
6 folder = path.exists(p)
7 if not folder:
8 makedirs(p)
187def _make_dirs(job_context: Dict):
188 dataset_id = str(job_context["dataset"].pk)
189 job_context["job_dir"] = "/home/user/data_store/smashed/" + dataset_id + "/"
190 os.makedirs(job_context["job_dir"], exist_ok=True)
191 job_context["output_dir"] = job_context["job_dir"] + "output/"
192 os.makedirs(job_context["output_dir"], exist_ok=True)
193 return job_context
43def _create_dir(parent: Path, name: str, mode: int) -> Path:
44 p = Path(parent, name)
45 p.mkdir()
46 p.chmod(mode)
47 return p
18def make_dirs(dirpath: str) -> None:
19 """Make directories for output if necessary"""
20 if not os.path.exists(dirpath):
21 os.makedirs(dirpath)
53def makedir(path):
54 if not os.path.exists(path):
55 os.makedirs(path)
1067def make_dir(dir_path):
1068 """
1069 Create directory recursively
1070 Args:
1071 dir_path (str): directory to be created
1072 """
1073
1074 try:
1075 os.makedirs(dir_path)
1076 except OSError:
1077 pass
1078 except:
1079 print cs.NOT_ABLE_TO_DELETE + dir_path

Related snippets