From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2201) id C61EE3858C53; Sat, 2 Jul 2022 21:07:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C61EE3858C53 To: cygwin-apps-cvs@sourceware.org Subject: [calm - Cygwin server-side packaging maintenance script] branch master, updated. 20220627-4-g879bfc5 X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 78dc0051e7f53830f72c219c437a5b175906dfd2 X-Git-Newrev: 879bfc586924cdaf42fc425fb71e7e145b8752a0 Message-Id: <20220702210709.C61EE3858C53@sourceware.org> Date: Sat, 2 Jul 2022 21:07:09 +0000 (GMT) From: Jon TURNEY X-BeenThere: cygwin-apps-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin-apps git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Jul 2022 21:07:09 -0000 https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=879bfc586924cdaf42fc425fb71e7e145b8752a0 commit 879bfc586924cdaf42fc425fb71e7e145b8752a0 Author: Jon Turney 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 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 '/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