diff options
author | Wolfgang Müller | 2024-09-19 19:07:44 +0200 |
---|---|---|
committer | Wolfgang Müller | 2024-09-19 19:07:44 +0200 |
commit | ae449a426f047c3574749b6ae1f5d2f5c28ad640 (patch) | |
tree | f82d2d5233dc5d98121e3554526a498ca831809a | |
parent | 5f9ebe5ef63cc80273de6981d112254a0e05e939 (diff) | |
download | later-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-x | later | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -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( |