From d66f185fdd6d3b578f5c375dce912f49d0f50028 Mon Sep 17 00:00:00 2001 From: dschlueter Date: Sun, 11 Oct 2026 23:30:29 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20abschliessen.py=20zeigt=20kleine=20Datei?= =?UTF-8?q?en=20in=20Byte=20statt=20=E2=80=9E0=20KB=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- abschliessen.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/abschliessen.py b/abschliessen.py index d404e31..ee1c7d5 100755 --- a/abschliessen.py +++ b/abschliessen.py @@ -119,9 +119,12 @@ def deletion_blockers(folder): def size(path): + """Size of a file or folder, readable: "830 B", "17 KB".""" if path.is_file(): - return path.stat().st_size - return sum(p.stat().st_size for p in path.rglob("*") if p.is_file()) + total = path.stat().st_size + else: + total = sum(p.stat().st_size for p in path.rglob("*") if p.is_file()) + return f"{total} B" if total < 1024 else f"{total / 1024:.0f} KB" def confirm(question): @@ -229,7 +232,7 @@ def main(): print(f"\nArbeitsordner {folder}:") for entry in sorted(folder.iterdir()): - print(f" {entry.name}{'/' if entry.is_dir() else ''} ({size(entry) / 1024:.0f} KB)") + print(f" {entry.name}{'/' if entry.is_dir() else ''} ({size(entry)})") if not args.ja and not confirm(f"Arbeitsordner {folder} löschen? [j/N] "): print("Nicht gelöscht.") return