diff --git a/.gitignore b/.gitignore index bc3c72e..ff8e58e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .* *.pyc +scripts/* diff --git a/README.rst b/README.rst index f5b8b9e..437ae50 100644 --- a/README.rst +++ b/README.rst @@ -48,6 +48,7 @@ RTV currently supports browsing both subreddits and individual submissions. In e :``▲``/``▼`` or ``j``/``k``: Scroll to the prev/next item :``o``: Open the selected item in the default web browser :``r`` or ``F5``: Refresh the current page +:``?``: Show the help message :``q``: Quit **Subreddit Mode** diff --git a/rtv/content.py b/rtv/content.py index 587057c..284bdf7 100644 --- a/rtv/content.py +++ b/rtv/content.py @@ -3,6 +3,7 @@ from datetime import datetime from contextlib import contextmanager import praw +import six import requests from .errors import SubmissionURLError, SubredditNameError @@ -123,6 +124,7 @@ class BaseContent(object): sub_author = (comment.submission.author.name if getattr(comment.submission, 'author') else '[deleted]') data['is_author'] = (data['author'] == sub_author) + data['flair'] = (comment.author_flair_text if comment.author_flair_text else "") return data @@ -147,6 +149,7 @@ class BaseContent(object): 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 "") data['url_full'] = sub.url data['url'] = ('selfpost' if is_selfpost(sub.url) else sub.url) @@ -342,11 +345,11 @@ class SubredditContent(BaseContent): # there is is no other way to check things like multireddits that # don't have a real corresponding subreddit object. content = cls(display_name, submissions, loader) - #try: - content.get(0) - #except: - # # TODO: Trap specific errors - # raise SubredditNameError(display_name) + try: + content.get(0) + except: + # TODO: Trap specific errors + raise SubredditNameError(display_name) return content diff --git a/rtv/main.py b/rtv/main.py index 70d9302..aa3899c 100644 --- a/rtv/main.py +++ b/rtv/main.py @@ -45,8 +45,8 @@ def main(): formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-s', dest='subreddit', help='subreddit name') parser.add_argument('-l', dest='link', help='full link to a submission') - parser.add_argument('--force-ascii', dest='force_ascii', - help='disable unicode', action='store_true') + parser.add_argument('--unicode', help='enable unicode (beta)', + action='store_true') group = parser.add_argument_group( 'authentication (optional)', @@ -64,7 +64,7 @@ def main(): if getattr(args, key) is None: setattr(args, key, val) - utils.FORCE_ASCII = args.force_ascii + utils.UNICODE = args.unicode if args.subreddit is None: args.subreddit = 'front' diff --git a/rtv/submission.py b/rtv/submission.py index 5598d1c..eef43f1 100644 --- a/rtv/submission.py +++ b/rtv/submission.py @@ -99,8 +99,7 @@ class SubmissionPage(BasePage): @staticmethod def draw_comment(win, data, inverted=False): - import logging - _logger = logging.getLogger(__name__) + n_rows, n_cols = win.getmaxyx() n_cols -= 1 @@ -114,13 +113,15 @@ class SubmissionPage(BasePage): attr = curses.A_BOLD attr |= (Color.BLUE if not data['is_author'] else Color.GREEN) win.addnstr(row, 1, clean(text), n_cols-1, attr) + text = ' {flair}'.format(**data) + win.addnstr(clean(text), n_cols-win.getyx()[1], curses.A_BOLD | Color.YELLOW) text = ' {score} {created}'.format(**data) win.addnstr(clean(text), n_cols - win.getyx()[1]) n_body = len(data['split_body']) for row, text in enumerate(data['split_body'], start=offset+1): if row in valid_rows: - win.addnstr(row, 1, clean(text), n_cols-50) + win.addnstr(row, 1, clean(text), n_cols-1) # Vertical line, unfortunately vline() doesn't support custom color so # we have to build it one chr at a time. @@ -174,6 +175,8 @@ class SubmissionPage(BasePage): attr = curses.A_BOLD | Color.GREEN text = '{author}'.format(**data) win.addnstr(row, 1, clean(text), n_cols, attr) + text = ' {flair}'.format(**data) + win.addnstr(clean(text), n_cols-win.getyx()[1], curses.A_BOLD | Color.YELLOW) text = ' {created} {subreddit}'.format(**data) win.addnstr(clean(text), n_cols - win.getyx()[1]) @@ -190,4 +193,4 @@ class SubmissionPage(BasePage): text = '{score} {comments}'.format(**data) win.addnstr(row, 1, clean(text), n_cols, curses.A_BOLD) - win.border() \ No newline at end of file + win.border() diff --git a/rtv/subreddit.py b/rtv/subreddit.py index b8d6a4a..f059c91 100644 --- a/rtv/subreddit.py +++ b/rtv/subreddit.py @@ -150,3 +150,5 @@ class SubredditPage(BasePage): win.addnstr(row, 1, clean(text), n_cols-1, curses.A_BOLD) text = ' {subreddit}'.format(**data) win.addnstr(clean(text), n_cols - win.getyx()[1], Color.YELLOW) + text = ' {flair}'.format(**data) + win.addnstr(clean(text), n_cols - win.getyx()[1], Color.RED) diff --git a/setup.py b/setup.py index 4374ef1..d31b06a 100644 --- a/setup.py +++ b/setup.py @@ -22,10 +22,7 @@ setup( 'Operating System :: POSIX', 'Natural Language :: English', 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.1', - 'Programming Language :: Python :: 3.2', - 'Programming Language :: Python :: 3.3', - 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3', 'Topic :: Terminals', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content :: Message Boards', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content :: News/Diary',