From ab18408b8261d6e9223317bc63586b288e96806e Mon Sep 17 00:00:00 2001 From: Luca Falavigna Date: Sun, 28 Apr 2013 10:06:37 +0000 Subject: [PATCH] Automatically remove empty directories --- dak/make_changelog.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dak/make_changelog.py b/dak/make_changelog.py index 939e8be1..2d52d069 100755 --- a/dak/make_changelog.py +++ b/dak/make_changelog.py @@ -243,7 +243,7 @@ def export_files(session, archive, clpool, progress=False): print 'make-changelog: unable to unpack %s\n%s' % (p, e) stats['errors'] += 1 - for root, dirs, files in os.walk(clpool): + for root, dirs, files in os.walk(clpool, topdown=False): files = [f for f in files if f != filelist] if len(files): if root != clpool: @@ -256,6 +256,11 @@ def export_files(session, archive, clpool, progress=False): if os.stat(os.path.join(root, file)).st_nlink == 1: stats['removed'] += 1 os.unlink(os.path.join(root, file)) + for dir in dirs: + try: + os.rmdir(os.path.join(root, dir)) + except OSError: + pass stats['files'] += len(files) stats['files'] -= stats['removed'] -- 2.39.5