aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorWolfgang Müller2024-09-19 19:07:44 +0200
committerWolfgang Müller2024-09-19 19:07:44 +0200
commitae449a426f047c3574749b6ae1f5d2f5c28ad640 (patch)
treef82d2d5233dc5d98121e3554526a498ca831809a
parent5f9ebe5ef63cc80273de6981d112254a0e05e939 (diff)
downloadlater-ae449a426f047c3574749b6ae1f5d2f5c28ad640.tar.gz
Have entries() continue early if an entry is not a file
This makes this already quite deeply nested function a bit easier to read.
-rwxr-xr-xlater22
1 files changed, 12 insertions, 10 deletions
diff --git a/later b/later
index 0ba6498..70e45e9 100755
--- a/later
+++ b/later
@@ -41,20 +41,22 @@ def entries():
with os.scandir(watch_later_dir) as entries:
for entry in sorted(entries, key=get_mtime):
- if entry.is_file():
- mtime = dt.fromtimestamp(get_mtime(entry))
+ if not entry.is_file():
+ continue
- with open(entry.path, "r") as handle:
- first = handle.readline().rstrip()
+ mtime = dt.fromtimestamp(get_mtime(entry))
- name = entry.name
- if first.startswith("# "):
- name = first.strip("# ")
+ with open(entry.path, "r") as handle:
+ first = handle.readline().rstrip()
- if name == "redirect entry":
- continue
+ name = entry.name
+ if first.startswith("# "):
+ name = first.strip("# ")
- yield entry.path, name, mtime
+ if name == "redirect entry":
+ continue
+
+ yield entry.path, name, mtime
parser = argparse.ArgumentParser(