Skip to content

Replace safe_mkdir(path) with os.makedirs(path, exist_ok=True) #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Replace safe_mkdir(path) with os.makedirs(path, exist_ok=True)
  • Loading branch information
hugovk committed Nov 10, 2024
commit 5934d4fb4ec8b3a30c13c477555c08ab42054dcf
11 changes: 3 additions & 8 deletions src/blurb/blurb.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,6 @@
os.chdir(self.previous_cwd)


def safe_mkdir(path):
if not os.path.exists(path):
os.makedirs(path)


def version_key(element):
fields = list(element.split("."))
if len(fields) == 1:
Expand Down Expand Up @@ -560,7 +555,7 @@

def save(self, path):
dirname = os.path.dirname(path)
safe_mkdir(dirname)
os.makedirs(dirname, exist_ok=True)

Check warning on line 558 in src/blurb/blurb.py

View check run for this annotation

Codecov / codecov/patch

src/blurb/blurb.py#L558

Added line #L558 was not covered by tests

text = str(self)
with open(path, "wt", encoding="utf-8") as file:
Expand Down Expand Up @@ -1178,12 +1173,12 @@
Creates and populates the Misc/NEWS.d directory tree.
"""
os.chdir("Misc")
safe_mkdir("NEWS.d/next")
os.makedirs("NEWS.d/next", exist_ok=True)

Check warning on line 1176 in src/blurb/blurb.py

View check run for this annotation

Codecov / codecov/patch

src/blurb/blurb.py#L1176

Added line #L1176 was not covered by tests

for section in sections:
dir_name = sanitize_section(section)
dir_path = f"NEWS.d/next/{dir_name}"
safe_mkdir(dir_path)
os.makedirs(dir_path, exist_ok=True)

Check warning on line 1181 in src/blurb/blurb.py

View check run for this annotation

Codecov / codecov/patch

src/blurb/blurb.py#L1181

Added line #L1181 was not covered by tests
readme_path = f"NEWS.d/next/{dir_name}/README.rst"
with open(readme_path, "wt", encoding="utf-8") as readme:
readme.write(f"Put news entry ``blurb`` files for the *{section}* section in this directory.\n")
Expand Down
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