Skip to content
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

Cleanup empty folders #17

Merged
merged 2 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.4
rev: v0.4.8
hooks:
- id: ruff-format
- id: ruff
Expand Down
7 changes: 7 additions & 0 deletions perdoo/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,13 @@ def start(settings: Settings, force: bool = False) -> None:
new_file.parent.mkdir(parents=True, exist_ok=True)
shutil.move(file, new_file)

for folder in sorted(
settings.collection_folder.rglob("*"), key=lambda p: len(p.parts), reverse=True
):
if folder.is_dir() and not any(folder.iterdir()):
folder.rmdir()
LOGGER.info("Deleted empty folder: %s", folder)


def main() -> None:
try:
Expand Down
10 changes: 6 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies = [
"mokkari@git+https://github.com/Buried-In-Code/mokkari ; python_version < \"3.10\"",
"natsort >= 8.4.0",
"pillow >= 10.3.0",
"pydantic >= 2.7.1",
"pydantic >= 2.7.3",
"rarfile >= 4.2",
"rich >= 13.7.1",
"simyan >= 1.2.1",
Expand All @@ -51,9 +51,6 @@ requires-python = ">= 3.8"
cb7 = [
"py7zr >= 0.21.0"
]
dev = [
"pre-commit >= 3.5.0"
]

[project.scripts]
Perdoo = "perdoo.__main__:main"
Expand Down Expand Up @@ -127,3 +124,8 @@ convention = "google"

[tool.ruff.lint.pyupgrade]
keep-runtime-typing = true

[tool.rye]
dev-dependencies = [
"pre-commit >= 3.5.0"
]
115 changes: 115 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: ["cb7"]
# all-features: false
# with-sources: false
# generate-hashes: false

-e file:.
annotated-types==0.7.0
# via pydantic
brotli==1.1.0
# via py7zr
certifi==2024.6.2
# via requests
cfgv==3.4.0
# via pre-commit
charset-normalizer==3.3.2
# via requests
distlib==0.3.8
# via virtualenv
esak==1.3.2
# via perdoo
eval-type-backport==0.2.0
# via mokkari
# via perdoo
# via simyan
filelock==3.14.0
# via virtualenv
himon==0.5.0
# via perdoo
identify==2.5.36
# via pre-commit
idna==3.7
# via requests
inflate64==1.0.0
# via py7zr
markdown-it-py==3.0.0
# via rich
marshmallow==3.21.2
# via esak
mdurl==0.1.2
# via markdown-it-py
mokkari @ git+https://github.com/Buried-In-Code/mokkari@44658ea65af15a672f52bd8b9572ee43ce41238b
# via perdoo
multivolumefile==0.2.3
# via py7zr
natsort==8.4.0
# via perdoo
nodeenv==1.9.1
# via pre-commit
packaging==24.0
# via marshmallow
pillow==10.3.0
# via perdoo
platformdirs==4.2.2
# via virtualenv
pre-commit==3.5.0
psutil==5.9.8
# via py7zr
py7zr==0.21.0
# via perdoo
pybcj==1.0.2
# via py7zr
pycryptodomex==3.20.0
# via py7zr
pydantic==2.7.3
# via himon
# via mokkari
# via perdoo
# via simyan
pydantic-core==2.18.4
# via pydantic
pygments==2.18.0
# via rich
pyppmd==1.1.0
# via py7zr
pyyaml==6.0.1
# via pre-commit
pyzstd==0.16.0
# via py7zr
rarfile==4.2
# via perdoo
ratelimit==2.2.1
# via himon
# via mokkari
# via simyan
requests==2.32.3
# via esak
# via himon
# via mokkari
# via simyan
rich==13.7.1
# via perdoo
simyan==1.2.1
# via perdoo
texttable==1.7.0
# via py7zr
tomli==2.0.1
# via perdoo
tomli-w==1.0.0
# via perdoo
typing-extensions==4.12.1
# via annotated-types
# via pydantic
# via pydantic-core
# via rich
urllib3==2.2.1
# via requests
virtualenv==20.26.2
# via pre-commit
xmltodict==0.13.0
# via perdoo
98 changes: 98 additions & 0 deletions requirements.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: ["cb7"]
# all-features: false
# with-sources: false
# generate-hashes: false

-e file:.
annotated-types==0.7.0
# via pydantic
brotli==1.1.0
# via py7zr
certifi==2024.6.2
# via requests
charset-normalizer==3.3.2
# via requests
esak==1.3.2
# via perdoo
eval-type-backport==0.2.0
# via mokkari
# via perdoo
# via simyan
himon==0.5.0
# via perdoo
idna==3.7
# via requests
inflate64==1.0.0
# via py7zr
markdown-it-py==3.0.0
# via rich
marshmallow==3.21.2
# via esak
mdurl==0.1.2
# via markdown-it-py
mokkari @ git+https://github.com/Buried-In-Code/mokkari@44658ea65af15a672f52bd8b9572ee43ce41238b
# via perdoo
multivolumefile==0.2.3
# via py7zr
natsort==8.4.0
# via perdoo
packaging==24.0
# via marshmallow
pillow==10.3.0
# via perdoo
psutil==5.9.8
# via py7zr
py7zr==0.21.0
# via perdoo
pybcj==1.0.2
# via py7zr
pycryptodomex==3.20.0
# via py7zr
pydantic==2.7.3
# via himon
# via mokkari
# via perdoo
# via simyan
pydantic-core==2.18.4
# via pydantic
pygments==2.18.0
# via rich
pyppmd==1.1.0
# via py7zr
pyzstd==0.16.0
# via py7zr
rarfile==4.2
# via perdoo
ratelimit==2.2.1
# via himon
# via mokkari
# via simyan
requests==2.32.3
# via esak
# via himon
# via mokkari
# via simyan
rich==13.7.1
# via perdoo
simyan==1.2.1
# via perdoo
texttable==1.7.0
# via py7zr
tomli==2.0.1
# via perdoo
tomli-w==1.0.0
# via perdoo
typing-extensions==4.12.1
# via annotated-types
# via pydantic
# via pydantic-core
# via rich
urllib3==2.2.1
# via requests
xmltodict==0.13.0
# via perdoo