diff --git a/rtv/__main__.py b/rtv/__main__.py index ff470df..40ed843 100644 --- a/rtv/__main__.py +++ b/rtv/__main__.py @@ -14,6 +14,7 @@ from .oauth import OAuthHelper from .terminal import Terminal from .objects import curses_session from .subreddit import SubredditPage +from .exceptions import ConfigError from .__version__ import __version__ @@ -106,6 +107,9 @@ def main(): # Launch the subreddit page page.loop() + except ConfigError as e: + _logger.exception(e) + print(e) except Exception as e: _logger.exception(e) raise diff --git a/rtv/exceptions.py b/rtv/exceptions.py index 8e4da1d..3e8fa6a 100644 --- a/rtv/exceptions.py +++ b/rtv/exceptions.py @@ -6,18 +6,14 @@ class EscapeInterrupt(Exception): "Signal that the ESC key has been pressed" +class ConfigError(Exception): + "There was a problem with the configuration" + + class RTVError(Exception): "Base RTV error class" -class KeystringError(RTVError): - "Unable to parse key string" - - -class ConfigError(RTVError): - "There was a problem with the configuration" - - class AccountError(RTVError): "Could not access user account" diff --git a/rtv/page.py b/rtv/page.py index 0e006b1..9441c2d 100644 --- a/rtv/page.py +++ b/rtv/page.py @@ -39,7 +39,6 @@ class Page(object): self.oauth = oauth self.content = None self.nav = None - self.controller = None self.active = True self._row = 0 diff --git a/rtv/rtv.cfg b/rtv/rtv.cfg index 8404827..6e88069 100644 --- a/rtv/rtv.cfg +++ b/rtv/rtv.cfg @@ -55,12 +55,12 @@ oauth_scope = edit,history,identity,mysubreddits,privatemessages,read,report,sav ############## # Key Bindings ############## -; Multiple keys that represent the same command should be listed as a comma -; seperated list. The a mixture of the following notations should be used to -; describe keys. +; If you would like to define custom bindings, copy this section into your +; config file with the [bindings] heading. All commands must be bound to at +; least one key for the config to be valid. ; ; 1.) Plain keys can be represented by either uppercase/lowercase characters -; or the hexadecimal codes referring their ascii codes. For reference, see +; or the hexadecimal numbers referring their ascii codes. For reference, see ; https://en.wikipedia.org/wiki/ASCII#ASCII_printable_code_chart ; e.g. Q, q, 1, ? ; e.g. 0x20 (space), 0x3c (less-than sign) @@ -77,9 +77,10 @@ oauth_scope = edit,history,identity,mysubreddits,privatemessages,read,report,sav ; Notes: ; - Curses is unreliable and should always be used in conjunction ; with . +; - Use 0x20 for the space key -; General keys -EXIT = q +; Base page +EXIT = q FORCE_EXIT = Q HELP = ? SORT_HOT = 1 @@ -115,4 +116,4 @@ SUBREDDIT_OPEN_SUBSCRIPTIONS = s ; Subscription page SUBSCRIPTION_SELECT = l, , , -SUBSCRIPTION_EXIT = h, s, , \ No newline at end of file +SUBSCRIPTION_EXIT = h, s, , diff --git a/rtv/submission.py b/rtv/submission.py index bfdc814..3e9fbe2 100644 --- a/rtv/submission.py +++ b/rtv/submission.py @@ -17,14 +17,13 @@ class SubmissionController(PageController): class SubmissionPage(Page): def __init__(self, reddit, term, config, oauth, url=None, submission=None): - super(SubmissionPage, self).__init__(reddit, term, config, oauth) + self.controller = SubmissionController(self, keymap=config.keymap) + super(SubmissionPage, self).__init__(reddit, term, config, oauth) if url: self.content = SubmissionContent.from_url(reddit, url, term.loader) else: self.content = SubmissionContent(submission, term.loader) - - self.controller = SubmissionController(self, keymap=config.keymap) # Start at the submission post, which is indexed as -1 self.nav = Navigator(self.content.get, page_index=-1) diff --git a/rtv/subreddit.py b/rtv/subreddit.py index 5c14339..95e3177 100644 --- a/rtv/subreddit.py +++ b/rtv/subreddit.py @@ -10,7 +10,6 @@ from .page import Page, PageController, logged_in from .objects import Navigator, Color, Command from .submission import SubmissionPage from .subscription import SubscriptionPage -from .terminal import Terminal class SubredditController(PageController): @@ -25,10 +24,10 @@ class SubredditPage(Page): name (string): Name of subreddit to open url (string): Optional submission to load upon start """ - super(SubredditPage, self).__init__(reddit, term, config, oauth) - - self.content = SubredditContent.from_name(reddit, name, term.loader) self.controller = SubredditController(self, keymap=config.keymap) + + super(SubredditPage, self).__init__(reddit, term, config, oauth) + self.content = SubredditContent.from_name(reddit, name, term.loader) self.nav = Navigator(self.content.get) @SubredditController.register(Command('REFRESH')) diff --git a/rtv/subscription.py b/rtv/subscription.py index 89f7877..d6dbda2 100644 --- a/rtv/subscription.py +++ b/rtv/subscription.py @@ -15,10 +15,10 @@ class SubscriptionController(PageController): class SubscriptionPage(Page): def __init__(self, reddit, term, config, oauth): - super(SubscriptionPage, self).__init__(reddit, term, config, oauth) - - self.content = SubscriptionContent.from_user(reddit, term.loader) self.controller = SubscriptionController(self, keymap=config.keymap) + + super(SubscriptionPage, self).__init__(reddit, term, config, oauth) + self.content = SubscriptionContent.from_user(reddit, term.loader) self.nav = Navigator(self.content.get) self.subreddit_data = None