PEP 8 (I'm bored): reddit

This commit is contained in:
enkore 2014-10-14 16:43:02 +02:00
parent 7b12be077d
commit d782621696

View File

@ -7,14 +7,13 @@ import praw
class Reddit(IntervalModule): class Reddit(IntervalModule):
""" """
This module fetches and displays posts and/or user mail/messages from This module fetches and displays posts and/or user mail/messages from
reddit.com. Left-clicking on the display text opens the permalink/comments reddit.com. Left-clicking on the display text opens the permalink/comments
page using webbrowser.open() while right-clicking opens the URL of the page using webbrowser.open() while right-clicking opens the URL of the
submission directly. Depends on the Python Reddit API Wrapper (PRAW) submission directly. Depends on the Python Reddit API Wrapper (PRAW)
<https://github.com/praw-dev/praw>. <https://github.com/praw-dev/praw>.
.. rubric:: Available formatters .. rubric:: Available formatters
* {submission_title} * {submission_title}
@ -68,7 +67,7 @@ class Reddit(IntervalModule):
@require(internet) @require(internet)
def run(self): def run(self):
r = praw.Reddit(user_agent='i3pystatus') r = praw.Reddit(user_agent='i3pystatus')
if self.password: if self.password:
r.login(self.username, self.password) r.login(self.username, self.password)
unread_messages = sum(1 for i in r.get_unread()) unread_messages = sum(1 for i in r.get_unread())
@ -113,7 +112,7 @@ class Reddit(IntervalModule):
fdict["submission_url"] = d["url"] fdict["submission_url"] = d["url"]
fdict["submission_domain"] = d["domain"] fdict["submission_domain"] = d["domain"]
fdict["submission_subreddit"] = d["subreddit"] fdict["submission_subreddit"] = d["subreddit"]
self._permalink = fdict["submission_permalink"] self._permalink = fdict["submission_permalink"]
self._url = fdict["submission_url"] self._url = fdict["submission_url"]
@ -125,7 +124,7 @@ class Reddit(IntervalModule):
color = self.color color = self.color
if len(fdict["submission_title"]) > self.title_maxlen: if len(fdict["submission_title"]) > self.title_maxlen:
title = fdict["submission_title"][:(self.title_maxlen-3)]+"..." title = fdict["submission_title"][:(self.title_maxlen - 3)] + "..."
fdict["submission_title"] = title fdict["submission_title"] = title
full_text = self.format.format(**fdict) full_text = self.format.format(**fdict)
@ -136,6 +135,6 @@ class Reddit(IntervalModule):
def on_leftclick(self): def on_leftclick(self):
user_open(self._permalink) user_open(self._permalink)
def on_rightclick(self): def on_rightclick(self):
user_open(self._url) user_open(self._url)