exclude for swp. fixing seconds for clock

This commit is contained in:
q
2024-06-26 10:54:14 +03:00
parent 6d750fb749
commit 1a315f100d
3 changed files with 27 additions and 11 deletions

Binary file not shown.

View File

@@ -22,7 +22,7 @@ try:
except ImportError:
MARKDOWN_AVAILABLE = False
VERSION = "20221124"
VERSION = "20240626"
IMAGE_EXTENSIONS = ["png", "gif", "jpg", "jpeg", "tif", "tiff"]
AUDIO_EXTENSIONS = ["wav", "mp3", "ogg"]
VIDEO_EXTENSIONS = ["mp4", "ogg", "webm"]
@@ -34,6 +34,7 @@ SAFE_OPTS = (
"images",
"media",
"includes",
"excludes",
"no_readme",
"no_wget",
"reverse",
@@ -141,6 +142,15 @@ def setup():
help="Glob match for files to be included in the table. ex. *.jpg. You can pass several includes.",
nargs="*",
)
parser.add_argument(
"--exclude",
"-e",
action="store",
dest="excludes",
default=[""],
help="Glob match for files to be excluded from the table. ex. *.jpg. You can pass several excludes.",
nargs="*",
)
parser.add_argument("--version", action="version", version=VERSION)
parser.add_argument(
"path",
@@ -247,8 +257,8 @@ def generate_index(opts):
print_setup(opts)
files = [f for f in files if f != opts.filename]
files = [f for f in files if f != opts.password_filename]
files = match_files(files, opts.includes)
dirs = match_files(dirs, opts.includes)
files = match_files(files, opts.includes, opts.excludes)
dirs = match_files(dirs, opts.includes, opts.excludes)
dirs.sort(reverse=opts.reverse)
files.sort(reverse=opts.reverse)
files.sort(key=lambda x: x.find("/") > 0)
@@ -1081,12 +1091,14 @@ def is_videofile(fname):
return False
def match_files(files, glob_list):
def match_files(files, include_list, exclude_list):
matched = []
for f in files:
for g in glob_list:
if fnmatch.fnmatch(f, g):
matched.append(f)
for in_g in include_list:
if fnmatch.fnmatch(f, in_g):
for ex_g in exclude_list:
if not fnmatch.fnmatch(f, ex_g):
matched.append(f)
break
return matched