From 2a0834734f11cadfea133157640f0caeeff466a4 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Fri, 20 Sep 2019 16:47:04 +0200 Subject: [PATCH] Allow skipping hidden and sorting --- CHANGELOG.md | 5 +++++ distribusi/cli.py | 5 +++++ distribusi/distribusi.py | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a57d686..23c06f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ The changelog was only added at version 0.0.4. +## 0.0.8 + +* Allow to ignore hidden directories with `--no-hidden` +* Files and directories are now sorted during distribusification. + ## 0.0.7 Let's think a bit about safety and robustness: diff --git a/distribusi/cli.py b/distribusi/cli.py index 0d45ebf..3afff70 100644 --- a/distribusi/cli.py +++ b/distribusi/cli.py @@ -72,6 +72,11 @@ def build_argparser(): help="Force whether distribusi overwrites or removes instances of index.html not generated by distribusi, use at own risk!", action="store_true") + parser.add_argument( + '--no-hidden', + help="Exclude hidden directories", + action="store_true") + return parser diff --git a/distribusi/distribusi.py b/distribusi/distribusi.py index 5a24ae0..81157aa 100644 --- a/distribusi/distribusi.py +++ b/distribusi/distribusi.py @@ -110,6 +110,13 @@ def distribusify(args, directory): # noqa print('Excluding directory:', ", ".join(args.exclude_directory)) dirs[:] = [d for d in dirs if d not in args.exclude_directory] + if args.no_hidden: + dirs = list(filter(lambda d: not d.startswith('.'), dirs)) + files = list(filter(lambda f: not f.startswith('.'), files)) + + dirs.sort() + files.sort() + if not args.remove_index: html = []