Safe call is useless here + some refactoring

This commit is contained in:
Théo Piboubès
2015-08-09 23:32:17 +02:00
parent be7cd1a071
commit 0274823b7e
2 changed files with 7 additions and 7 deletions

View File

@@ -368,21 +368,22 @@ class SubredditContent(BaseContent):
return data return data
class SubscriptionContent(BaseContent): class SubscriptionContent(BaseContent):
def __init__(self, subscriptions, loader): def __init__(self, name, subscriptions, loader):
self.name = "Subscriptions" self.name = name
self._loader = loader self._loader = loader
self._subscriptions = subscriptions self._subscriptions = subscriptions
self._subscription_data = [] self._subscription_data = []
@classmethod @classmethod
def get_list(cls, reddit, loader): def get_list(cls, reddit, loader):
display_name = "Subscriptions"
try: try:
with loader(): with loader():
subscriptions = reddit.get_my_subreddits(limit=None) subscriptions = reddit.get_my_subreddits(limit=None)
except praw.errors.APIException: except praw.errors.APIException:
raise SubscriptionError() raise SubscriptionError()
return cls(subscriptions, loader) return cls(display_name, subscriptions, loader)
def get(self, index, n_cols=70): def get(self, index, n_cols=70):
""" """

View File

@@ -167,10 +167,9 @@ class SubredditPage(BasePage):
show_notification(self.stdscr, ['Not logged in']) show_notification(self.stdscr, ['Not logged in'])
return return
with self.safe_call as s: page = SubscriptionPage(self.stdscr, self.reddit)
page = SubscriptionPage(self.stdscr, self.reddit) page.loop()
page.loop() self.refresh_content()
self.refresh_content()
@staticmethod @staticmethod
def draw_item(win, data, inverted=False): def draw_item(win, data, inverted=False):