From 793e4344e246dcd57cccae8c1d4c3e454df7464d Mon Sep 17 00:00:00 2001 From: amadejpapez Date: Mon, 26 Dec 2022 15:32:47 +0100 Subject: [PATCH] style: code changes --- src/format_post.py | 15 ++++++++------- src/main.py | 1 - src/posting.py | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/format_post.py b/src/format_post.py index d30b13c..099db54 100644 --- a/src/format_post.py +++ b/src/format_post.py @@ -33,8 +33,8 @@ def new_updates(releases: list) -> list: if len(releases) == 1: post_text.insert(0, ":collision: NEW UPDATE RELEASED :collision:\n\n") + # if there is only one release, add its notes as a link instead if releases[0].get_security_content_link(): - # if there is only one release, add its notes as a link post_text.append(releases[0].get_security_content_link()) else: post_text.insert(0, ":collision: NEW UPDATES RELEASED :collision:\n\n") @@ -45,7 +45,7 @@ def new_updates(releases: list) -> list: def top_ios_modules(releases: list) -> list: """ - ----------------------------- + ----- ⚒ FIXED IN iOS 14.7 ⚒ - 4 bugs in WebKit @@ -54,7 +54,7 @@ def top_ios_modules(releases: list) -> list: - 2 bugs in CoreAudio and 25 other vulnerabilities fixed https://support.apple.com/kb/HT212601 - ----------------------------- + ----- """ post_text = [] @@ -76,12 +76,13 @@ def top_ios_modules(releases: list) -> list: for key, value in modules.items(): if len(post_text) < 5: - num_bugs += value if value > 1: post_text.append(f"- {value} bugs in {key}\n") else: post_text.append(f"- {value} bug in {key}\n") + num_bugs += value + num_bugs = release.get_num_of_bugs() - num_bugs if num_bugs > 0: @@ -226,15 +227,15 @@ def entry_changes(releases: list) -> list: elif release.get_num_entries_updated() > 0: post_text.append(f"{name} - {release.get_format_num_entries_updated()}\n") - if changes_count > 1: + if changes_count == 1: post_text.insert( 0, - f":arrows_counterclockwise: {changes_count} ENTRY CHANGES :arrows_counterclockwise:\n\n", + ":arrows_counterclockwise: 1 ENTRY CHANGE :arrows_counterclockwise:\n\n", ) else: post_text.insert( 0, - ":arrows_counterclockwise: 1 ENTRY CHANGE :arrows_counterclockwise:\n\n", + f":arrows_counterclockwise: {changes_count} ENTRY CHANGES :arrows_counterclockwise:\n\n", ) return post_text diff --git a/src/main.py b/src/main.py index 67f516e..b12949c 100644 --- a/src/main.py +++ b/src/main.py @@ -116,7 +116,6 @@ def check_for_entry_changes(coll: dict, all_releases_rows: list) -> None: Because of checking so many releases and to not make too much requests, it is only doing this once per day. """ - for row in all_releases_rows: release = Release(row) diff --git a/src/posting.py b/src/posting.py index 2580887..f7d400a 100644 --- a/src/posting.py +++ b/src/posting.py @@ -17,7 +17,7 @@ return_type=type(dict), ) -MASTODON_API = { +MASTODON_KEYS = { "access_token": ("Bearer " + KEYS["Mastodon_ApplSec"]["access_token"]), } @@ -87,7 +87,7 @@ def toot(results: list) -> None: response = requests.post( API_URL, json={"status": emoji.emojize(text, language="alias")}, - headers={"Authorization": MASTODON_API["access_token"]}, + headers={"Authorization": MASTODON_KEYS["access_token"]}, timeout=60 ) @@ -100,7 +100,7 @@ def toot(results: list) -> None: "status": emoji.emojize(text, language="alias"), "in_reply_to_id": post_ids[-1], }, - headers={"Authorization": MASTODON_API["access_token"]}, + headers={"Authorization": MASTODON_KEYS["access_token"]}, timeout=60 )