ListRedditsContent.from_user method replaced with from_func; updated tests accordingly

This commit is contained in:
woorst
2016-07-17 19:52:35 -05:00
parent 96151408b3
commit bfba1c7ad2
6 changed files with 33 additions and 42 deletions

View File

@@ -388,7 +388,7 @@ class SubredditContent(Content):
# Strip leading, trailing, and redundant backslashes
name_list = [seg for seg in name.strip(' /').split('/') if seg]
name_order = None
if name_list[0] in ['r', 'u', 'user', 'domain'] and len(name_list) > 1:
if len(name_list) > 1 and name_list[0] in ['r', 'u', 'user', 'domain']:
listing, name_list = name_list[0], name_list[1:]
if len(name_list) == 2:
name, name_order = name_list
@@ -540,8 +540,8 @@ class ListRedditsContent(Content):
raise exceptions.ListRedditsError('No {}'.format(self.name))
@classmethod
def from_user(cls, name, reddits, loader):
reddits = (r for r in reddits)
def from_func(cls, name, func, loader):
reddits = (r for r in func())
return cls(name, reddits, loader)
def get(self, index, n_cols=70):