MCPcopy
hub / github.com/praw-dev/praw / karma

Method karma

praw/models/user.py:105–124  ·  view source on GitHub ↗

r"""Return a dictionary mapping :class:`.Subreddit`\ s to their karma. The returned dict contains subreddits as keys. Each subreddit key contains a sub-dict that have keys for ``comment_karma`` and ``link_karma``. The dict is sorted in descending karma order. .. not

(self)

Source from the content-addressed store, hash-verified

103 return self._reddit.get(endpoint)
104
105 def karma(self) -> dict[models.Subreddit, dict[str, int]]:
106 r"""Return a dictionary mapping :class:`.Subreddit`\ s to their karma.
107
108 The returned dict contains subreddits as keys. Each subreddit key contains a
109 sub-dict that have keys for ``comment_karma`` and ``link_karma``. The dict is
110 sorted in descending karma order.
111
112 .. note::
113
114 Each key of the main dict is an instance of :class:`.Subreddit`. It is
115 recommended to iterate over the dict in order to retrieve the values,
116 preferably through :py:meth:`dict.items`.
117
118 """
119 karma_map = {}
120 for row in self._reddit.get(API_PATH["karma"])["data"]:
121 subreddit = Subreddit(self._reddit, row["sr"])
122 del row["sr"]
123 karma_map[subreddit] = row
124 return karma_map
125
126 def me(self, *, use_cache: bool = True) -> models.Redditor | None:
127 """Return a :class:`.Redditor` instance for the authenticated user.

Callers 1

test_karmaMethod · 0.80

Calls 2

SubredditClass · 0.90
getMethod · 0.80

Tested by 1

test_karmaMethod · 0.64