From ac98f564a38ad61fe93a18dd802332af7383c2da Mon Sep 17 00:00:00 2001 From: Tobin Date: Tue, 31 Mar 2015 09:38:20 -0500 Subject: [PATCH] fixed some janky things that autopep8 did --- rtv/content.py | 31 +++++++++++-------------------- rtv/exceptions.py | 12 ++++-------- rtv/subreddit.py | 9 ++------- 3 files changed, 17 insertions(+), 35 deletions(-) diff --git a/rtv/content.py b/rtv/content.py index bdebb6d..72899e9 100644 --- a/rtv/content.py +++ b/rtv/content.py @@ -72,16 +72,12 @@ class BaseContent(object): data['body'] = comment.body data['created'] = humanize_timestamp(comment.created_utc) data['score'] = '{} pts'.format(comment.score) - data['author'] = ( - comment.author.name if getattr( - comment, - 'author') else '[deleted]') - data['is_author'] = ( - data['author'] == getattr( - comment.submission, - 'author')) - data['flair'] = ( - comment.author_flair_text if comment.author_flair_text else '') + author = getattr(comment, 'author') + data['author'] = (author.name if author else '[deleted]') + sub_author = getattr(comment.submission, 'author') + data['is_author'] = (data['author'] == sub_author) + flair = comment.author_flair_text + data['flair'] = (flair if flair else '') data['likes'] = comment.likes return data @@ -103,10 +99,8 @@ class BaseContent(object): data['created'] = humanize_timestamp(sub.created_utc) data['comments'] = '{} comments'.format(sub.num_comments) data['score'] = '{} pts'.format(sub.score) - data['author'] = ( - sub.author.name if getattr( - sub, - 'author') else '[deleted]') + author = getattr(sub, 'author') + data['author'] = (author.name if author else '[deleted]') data['permalink'] = sub.permalink data['subreddit'] = strip_subreddit_url(sub.permalink) data['flair'] = (sub.link_flair_text if sub.link_flair_text else '') @@ -169,13 +163,10 @@ class SubmissionContent(BaseContent): elif index == -1: data = self._submission_data - data['split_title'] = textwrap.wrap( - data['title'], - width=n_cols - - 2) + data['split_title'] = textwrap.wrap(data['title'], + width=n_cols -2) data['split_text'] = wrap_text(data['text'], width=n_cols - 2) - data['n_rows'] = len( - data['split_title']) + len(data['split_text']) + 5 + data['n_rows'] = len(data['split_title']) + len(data['split_text']) + 5 data['offset'] = 0 else: diff --git a/rtv/exceptions.py b/rtv/exceptions.py index d502975..9f2e61c 100644 --- a/rtv/exceptions.py +++ b/rtv/exceptions.py @@ -1,27 +1,23 @@ class SubmissionError(Exception): - - "Submission could not be loaded" + """Submission could not be loaded""" def __init__(self, url): self.url = url class SubredditError(Exception): - - "Subreddit could not be reached" + """Subreddit could not be reached""" def __init__(self, name): self.name = name class ProgramError(Exception): - - "Problem executing an external program" + """Problem executing an external program""" def __init__(self, name): self.name = name class EscapeInterrupt(Exception): - - "Signal that the ESC key has been pressed" + """Signal that the ESC key has been pressed""" diff --git a/rtv/subreddit.py b/rtv/subreddit.py index 5587bca..5dfe990 100644 --- a/rtv/subreddit.py +++ b/rtv/subreddit.py @@ -59,13 +59,8 @@ class SubredditPage(BasePage): n_rows, n_cols = self.stdscr.getmaxyx() self.stdscr.addstr(n_rows - 1, 0, prompt, attr) self.stdscr.refresh() - window = self.stdscr.derwin( - 1, - n_cols - - len(prompt), - n_rows - - 1, - len(prompt)) + window = self.stdscr.derwin(1, n_cols - len(prompt), + n_rows - 1, len(prompt)) window.attrset(attr) out = text_input(window)