Skip to content

Commit

Permalink
Replace safe_mkdir(path) with os.makedirs(path, exist_ok=True)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Nov 10, 2024
1 parent 255d115 commit 5934d4f
Showing 1 changed file with 3 additions and 8 deletions.
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 @@ def __exit__(self, *args):
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 __str__(self):

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 @@ def populate():
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

0 comments on commit 5934d4f

Please sign in to comment.