Skip to content

Commit e17700d

Browse files
authored
Replace safe_mkdir(path) with os.makedirs(path, exist_ok=True) (#38)
2 parents 255d115 + 5934d4f commit e17700d

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/blurb/blurb.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,6 @@ def __exit__(self, *args):
268268
os.chdir(self.previous_cwd)
269269

270270

271-
def safe_mkdir(path):
272-
if not os.path.exists(path):
273-
os.makedirs(path)
274-
275-
276271
def version_key(element):
277272
fields = list(element.split("."))
278273
if len(fields) == 1:
@@ -560,7 +555,7 @@ def __str__(self):
560555

561556
def save(self, path):
562557
dirname = os.path.dirname(path)
563-
safe_mkdir(dirname)
558+
os.makedirs(dirname, exist_ok=True)
564559

565560
text = str(self)
566561
with open(path, "wt", encoding="utf-8") as file:
@@ -1178,12 +1173,12 @@ def populate():
11781173
Creates and populates the Misc/NEWS.d directory tree.
11791174
"""
11801175
os.chdir("Misc")
1181-
safe_mkdir("NEWS.d/next")
1176+
os.makedirs("NEWS.d/next", exist_ok=True)
11821177

11831178
for section in sections:
11841179
dir_name = sanitize_section(section)
11851180
dir_path = f"NEWS.d/next/{dir_name}"
1186-
safe_mkdir(dir_path)
1181+
os.makedirs(dir_path, exist_ok=True)
11871182
readme_path = f"NEWS.d/next/{dir_name}/README.rst"
11881183
with open(readme_path, "wt", encoding="utf-8") as readme:
11891184
readme.write(f"Put news entry ``blurb`` files for the *{section}* section in this directory.\n")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy