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>2017-04-08 23:11:18 +0300
committerJon Turney <jon.turney@dronecode.org.uk>2017-04-10 00:06:30 +0300
commitae33541488c402a3461e75d89241eb7f7ddf8deb (patch)
treeaf9ca19e287c4fc0af11ce38a6adf78827b89248
parent9f8aa81b7ddcdec5e923f8ef7aea8fdb1da43483 (diff)
Remove directories which are empty after updating package listing
-rwxr-xr-xcalm/pkg2html.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/calm/pkg2html.py b/calm/pkg2html.py
index f6b260c..70af62d 100755
--- a/calm/pkg2html.py
+++ b/calm/pkg2html.py
@@ -31,8 +31,8 @@
# --- if a package listing HTML file doesn't already exist
# ---- write a HTML package listing file listing the tar file contents
# - write packages.inc, the list of packages
-# - remove any listing files for which there was no package
-# - remove any empty directories (TBD)
+# - remove any .htaccess or listing files for which there was no package
+# - remove any directories which are now empty
#
# note that the directory hierarchy of (noarch|arch)/package/subpackages is
# flattened in the package listing to just the package name
@@ -84,7 +84,7 @@ def update_package_listings(args, packages, arch):
print('Redirect temp /packages/%s/index.html https://cygwin.com/packages/package_list.html' % (arch),
file=f)
- toremove = glob.glob(os.path.join(base, '*', '*'))
+ toremove = glob.glob(os.path.join(base, '*', '*')) + glob.glob(os.path.join(base, '*', '.*'))
for p in packages:
@@ -119,6 +119,10 @@ def update_package_listings(args, packages, arch):
# doesn't help for src packages, so is it actually having
# any effect?
+ # this file should exist, so remove from the toremove list
+ if htaccess in toremove:
+ toremove.remove(htaccess)
+
#
# for each tarfile, write tarfile listing
#
@@ -220,7 +224,7 @@ def update_package_listings(args, packages, arch):
</div>'''), file=index)
#
- # remove any remaining listing files for which there was no corresponding package
+ # remove any remaining files for which there was no corresponding package
#
for r in toremove:
@@ -228,6 +232,16 @@ def update_package_listings(args, packages, arch):
if not args.dryrun:
os.unlink(r)
+ #
+ # remove any directories which are now empty
+ #
+
+ dirpath = os.path.dirname(r)
+ if len(os.listdir(dirpath)) == 0:
+ logging.debug('rmdir %s' % dirpath)
+ os.rmdir(os.path.join(dirpath))
+
+
if __name__ == "__main__":
htdocs_default = os.path.join(common_constants.HTDOCS, 'packages')
relarea_default = common_constants.FTP