From 20410849622c137d55b2f2513442da5049dfc7e9 Mon Sep 17 00:00:00 2001 From: Shane Date: Wed, 7 May 2025 19:52:11 +1000 Subject: [PATCH] dictionary structure of X_API_CREDENTIALS --- foodie_engagement_tweet.py | 2 +- foodie_utils.py | 2 +- foodie_weekly_thread.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/foodie_engagement_tweet.py b/foodie_engagement_tweet.py index 2372e0b..0e3d6d1 100644 --- a/foodie_engagement_tweet.py +++ b/foodie_engagement_tweet.py @@ -126,7 +126,7 @@ def get_reference_date(): def generate_engagement_tweet(author): """Generate an engagement tweet using author background themes.""" - credentials = next((cred for cred in X_API_CREDENTIALS if cred["username"] == author["username"]), None) + credentials = X_API_CREDENTIALS.get(author["username"]) if not credentials: logging.error(f"No X credentials found for {author['username']}") return None diff --git a/foodie_utils.py b/foodie_utils.py index a23d050..49dd207 100644 --- a/foodie_utils.py +++ b/foodie_utils.py @@ -216,7 +216,7 @@ def post_tweet(author, tweet, reply_to_id=None): import tweepy from datetime import datetime, timezone - credentials = next((cred for cred in X_API_CREDENTIALS if cred["username"] == author["username"]), None) + credentials = X_API_CREDENTIALS.get(author["username"]) if not credentials: logging.error(f"No X credentials found for {author['username']}") return False diff --git a/foodie_weekly_thread.py b/foodie_weekly_thread.py index 374a11c..dfe41b1 100644 --- a/foodie_weekly_thread.py +++ b/foodie_weekly_thread.py @@ -100,7 +100,7 @@ def validate_twitter_credentials(): logging.info("Validating Twitter API credentials for all authors") valid_credentials = [] for author in AUTHORS: - credentials = next((cred for cred in X_API_CREDENTIALS if cred["username"] == author["username"]), None) + credentials = X_API_CREDENTIALS.get(author["username"]) if not credentials: logging.error(f"No X credentials found for {author['username']} in X_API_CREDENTIALS") continue