]> err.no Git - dak/commitdiff
Automatically remove empty directories
authorLuca Falavigna <dktrkranz@debian.org>
Sun, 28 Apr 2013 10:06:37 +0000 (10:06 +0000)
committerLuca Falavigna <dktrkranz@debian.org>
Sun, 28 Apr 2013 10:06:37 +0000 (10:06 +0000)
dak/make_changelog.py

index 939e8be106aa3a8ae82d7464f919ff1f6b243a8f..2d52d0693a461dd071b42a30ddff8e4cb0366d6f 100755 (executable)
@@ -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']