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

View File

@@ -101,9 +101,8 @@ def saddstr(win, y, x, s, a=None):
pass pass
def drawcircle(win, cy, cx, r, s="·", attr=None): def drawcircle(win, cy, cx, r, s="·", attr=None, precision=360):
# TODO: get seconds?, color by angle, darkening to past. current seconds bright # TODO: get seconds?, color by angle, darkening to past. current seconds bright
precision = 360
for a in range(precision): for a in range(precision):
alpha = 2.0 * math.pi * a / precision alpha = 2.0 * math.pi * a / precision
dy = int(round(cy - float(r) * math.cos(alpha))) dy = int(round(cy - float(r) * math.cos(alpha)))
@@ -233,6 +232,7 @@ def main():
is_alarm = False is_alarm = False
t_old = time.localtime(time.time()) t_old = time.localtime(time.time())
tick_tock = False tick_tock = False
exact_seconds = options.refresh % 1 == 0
try: try:
# rows,columns = termsize() # rows,columns = termsize()
curses.cbreak() curses.cbreak()
@@ -247,7 +247,7 @@ def main():
t_h, t_m = divmod(t_m, 60) t_h, t_m = divmod(t_m, 60)
f = 0 f = 0
else: else:
f = now % 1 f = 0 if exact_seconds else now % 1
t_s = float(t.tm_sec) t_s = float(t.tm_sec)
t_m = float(t.tm_min) t_m = float(t.tm_min)
t_h = float(t.tm_hour) t_h = float(t.tm_hour)
@@ -260,12 +260,16 @@ def main():
tick_tock = not tick_tock if options.refresh > 1 else t.tm_sec % 2 tick_tock = not tick_tock if options.refresh > 1 else t.tm_sec % 2
#for s in range(60):
# drawline(stdscr, cy, cx, math.pi * s / 30.0, r-2, r / 2, "∙",
# attr=curses.color_pair(2) + curses.A_BOLD + curses.A_BLINK if is_alarm else curses.color_pair(8))
drawcircle( drawcircle(
stdscr, stdscr,
cy, cy,
cx, cx,
r / 2, r / 2,
attr=curses.color_pair(2) + curses.A_BOLD + curses.A_BLINK if is_alarm else curses.color_pair(1), attr=curses.color_pair(2) + curses.A_BOLD + curses.A_BLINK if is_alarm else curses.color_pair(8),
precision=60
) )
if options.seconds: if options.seconds:
drawline(stdscr, cy, cx, alphas, 1, r / 2, "■", curses.color_pair(2)) drawline(stdscr, cy, cx, alphas, 1, r / 2, "■", curses.color_pair(2))

Binary file not shown.

View File

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