public inbox for cygwin-apps-cvs@sourceware.org
help / color / mirror / Atom feed
* [calm - Cygwin server-side packaging maintenance script] branch master, updated. 20220627-4-g879bfc5
@ 2022-07-02 21:07 Jon TURNEY
  0 siblings, 0 replies; only message in thread
From: Jon TURNEY @ 2022-07-02 21:07 UTC (permalink / raw)
  To: cygwin-apps-cvs




https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=879bfc586924cdaf42fc425fb71e7e145b8752a0

commit 879bfc586924cdaf42fc425fb71e7e145b8752a0
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Sat Jul 2 22:03:26 2022 +0100

    Ignore flake8-bugbear B023
    
    I seem to like writing code which I think legitimately use the construct
    this warns about.
    
    Drop ignoring B020, since false positives are fixed.

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=130b929a2c7d4fbc28bedcbdbac7214acdacf328

commit 130b929a2c7d4fbc28bedcbdbac7214acdacf328
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Sat Jul 2 20:29:08 2022 +0100

    Only remove empty subdirectories below a certain depth
    
    'cygport upload/stage' assumes the existence of the '<arch>/release'
    directories, so don't remove those, even if empty.


Diff:
---
 .flake8       | 2 +-
 calm/utils.py | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/.flake8 b/.flake8
index 48e7f81..7c03237 100644
--- a/.flake8
+++ b/.flake8
@@ -1,5 +1,5 @@
 [flake8]
-ignore=E741,E129,W504,A003,B020,B902
+ignore=E741,E129,W504,A003,B023,B902
 max-line-length=240
 per-file-ignores =
   calm/fixes.py:E241,E127
diff --git a/calm/utils.py b/calm/utils.py
index f25e5f4..bafc5ff 100644
--- a/calm/utils.py
+++ b/calm/utils.py
@@ -58,12 +58,12 @@ def makedirs(name):
 
 
 #
-# remove any empty subdirectories
+# remove any empty subdirectories below a given depth
 #
-def rmemptysubdirs(path):
+def rmemptysubdirs(path, depth=3):
     for (dirpath, _subdirs, _files) in os.walk(path, topdown=False, followlinks=True):
-        # don't remove the given directory, only subdirectories
-        if os.path.relpath(dirpath, path) == '.':
+        # don't do anything while above the given depth
+        if len(os.path.relpath(dirpath, path).split(os.sep)) < depth:
             continue
 
         # check whether the directory is now empty after processing any



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-02 21:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-02 21:07 [calm - Cygwin server-side packaging maintenance script] branch master, updated. 20220627-4-g879bfc5 Jon TURNEY

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).