From 6072d70aeaaffd4c5f6cf8ef3fd88fafa50b33c6 Mon Sep 17 00:00:00 2001 From: Nathan Windisch Date: Wed, 24 Jul 2024 22:37:26 +0100 Subject: [PATCH] Created RedditPageData class, for outputing various data components from the RedditPage class --- src/reddit.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/reddit.py b/src/reddit.py index 10e3a52..f0e35e8 100644 --- a/src/reddit.py +++ b/src/reddit.py @@ -24,11 +24,14 @@ class RedditPageType(Enum): SUBREDDIT_COMMENTS = "r" USER_COMMENTS = "u" - "author_username": item["author"], - "author_id": item["author_fullname"], - "subreddit_name": item["subreddit"], - "subreddit_id": item["subreddit_id"], - "subreddit_subscribers": item["subreddit_subscribers"], +class RedditPageData: + def __init__(self, uri: str = "", posts: list = [], comments: list = [], after: str = ""): + self.uri = uri + self.posts = posts + self.comments = comments + self.after = after + def __str__(self): return json.dumps({ "uri": self.uri, "posts": self.posts, "comments": self.comments, "after": self.after }) + "score": item["score"], "upvotes": item["ups"],