Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/cygwin-apps/calm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2022-07-02 22:29:08 +0300
committerJon Turney <jon.turney@dronecode.org.uk>2022-07-02 23:23:46 +0300
commit130b929a2c7d4fbc28bedcbdbac7214acdacf328 (patch)
treef108c485a2463e3a99524c5d5625a8d059d30a52
parent78dc0051e7f53830f72c219c437a5b175906dfd2 (diff)
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.
-rw-r--r--calm/utils.py8
1 files changed, 4 insertions, 4 deletions
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