Skip to content

Commit a0da7a8

Browse files
committed
feat: add method that accepts filepath and cleans empty parents directories
1 parent f45320d commit a0da7a8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

iarp_django_utils/helpers.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def get_param_name_for_queryset_filter(key: str):
7676

7777

7878
def clean_empty_parent_directories(directory: pathlib.Path, depth: int, raise_on_error=False):
79+
directory = pathlib.Path(directory)
7980

8081
for x in range(depth):
8182
try:
@@ -85,3 +86,11 @@ def clean_empty_parent_directories(directory: pathlib.Path, depth: int, raise_on
8586
raise
8687

8788
directory = directory.parent
89+
90+
91+
def clean_file_empty_parent_directories(filepath: pathlib.Path, depth: int, raise_on_error=False):
92+
clean_empty_parent_directories(
93+
directory=pathlib.Path(filepath).parent,
94+
depth=depth,
95+
raise_on_error=raise_on_error,
96+
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
55
[project]
66
name = "iarp_django_utils"
77
description = "A personal collection of common django utilities used in various projects."
8-
version = "2025.5.29"
8+
version = "2025.6.11"
99
requires-python = ">= 3.0"
1010
readme = "readme.rst"
1111
keywords = ["django", "utilities"]

0 commit comments

Comments
 (0)