summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2024-10-05 19:58:51 +0100
committerV3n3RiX <venerix@koprulu.sector>2024-10-05 19:58:51 +0100
commitec51bc4be021116013a56a55fc6eb804887c2034 (patch)
tree8f8b7817ed24d3393a3bbd1d4972ca314a7397dc
parent3686bbcd8d465fdd79782d3da8285930b679db02 (diff)
make checking news more portable
-rw-r--r--src/backend/getnews.py13
-rwxr-xr-xsrc/frontend/cli/sisyphus-cli.py3
2 files changed, 7 insertions, 9 deletions
diff --git a/src/backend/getnews.py b/src/backend/getnews.py
index ce56df4..b2d2978 100644
--- a/src/backend/getnews.py
+++ b/src/backend/getnews.py
@@ -42,7 +42,8 @@ def mark_read(article_nr):
r_news_index = ld_r_news()
if article_index in r_news_index:
- print(f"\nArticle {sisyphus.getclr.green}{article_nr}{sisyphus.getclr.reset} is already marked as {sisyphus.getclr.green}read{sisyphus.getclr.reset}.")
+ print(
+ f"\nArticle {sisyphus.getclr.green}{article_nr}{sisyphus.getclr.reset} is already marked as {sisyphus.getclr.green}read{sisyphus.getclr.reset}.")
else:
r_news_index.append(article_index)
save_r_news(r_news_index)
@@ -61,7 +62,8 @@ def mark_unread(article_nr):
r_news_index = ld_r_news()
if article_index not in r_news_index:
- print(f"\nArticle {sisyphus.getclr.green}{article_nr}{sisyphus.getclr.reset} is already marked as {sisyphus.getclr.green}unread{sisyphus.getclr.reset}.")
+ print(
+ f"\nArticle {sisyphus.getclr.green}{article_nr}{sisyphus.getclr.reset} is already marked as {sisyphus.getclr.green}unread{sisyphus.getclr.reset}.")
else:
r_news_index.remove(article_index)
save_r_news(r_news_index)
@@ -88,12 +90,7 @@ def check_n_news():
unread_count = len(n_news) - len(r_news_index)
- if unread_count > 0:
- print(
- f"\nThere are {sisyphus.getclr.bright_red}{unread_count}{sisyphus.getclr.reset} unread news article(s).")
- else:
- print(
- f"\nThere are {sisyphus.getclr.green}{unread_count}{sisyphus.getclr.reset} unread news article(s).")
+ return unread_count
def start(check=False, list=False, read=False, unread=False, article_nr=None):
diff --git a/src/frontend/cli/sisyphus-cli.py b/src/frontend/cli/sisyphus-cli.py
index 053f111..076bce3 100755
--- a/src/frontend/cli/sisyphus-cli.py
+++ b/src/frontend/cli/sisyphus-cli.py
@@ -357,7 +357,8 @@ def checknews():
* Example:\n
sisyphus news check\n
"""
- sisyphus.getnews.start(check=True)
+ unread_count = sisyphus.getnews.start(check=True)
+ print(f"\nThere are {unread_count} unread news article(s).\n")
@getNews.command("list")