Increased stability for self posts. Still more work to be done.
This commit is contained in:
@@ -55,6 +55,18 @@ def default_loader(self):
|
|||||||
|
|
||||||
class BaseContent(object):
|
class BaseContent(object):
|
||||||
|
|
||||||
|
def get(self, index, n_cols):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def iterate(self, index, step, n_cols):
|
||||||
|
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
yield self.get(index, n_cols)
|
||||||
|
except IndexError:
|
||||||
|
break
|
||||||
|
index += step
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def flatten_comments(comments, root_level=0):
|
def flatten_comments(comments, root_level=0):
|
||||||
"""
|
"""
|
||||||
@@ -251,12 +263,6 @@ class SubmissionContent(BaseContent):
|
|||||||
else:
|
else:
|
||||||
raise ValueError('% type not recognized' % data['type'])
|
raise ValueError('% type not recognized' % data['type'])
|
||||||
|
|
||||||
def iterate(self, index, step, n_cols=70):
|
|
||||||
|
|
||||||
while True:
|
|
||||||
yield self.get(index, n_cols=n_cols)
|
|
||||||
index += step
|
|
||||||
|
|
||||||
|
|
||||||
class SubredditContent(BaseContent):
|
class SubredditContent(BaseContent):
|
||||||
"""
|
"""
|
||||||
@@ -315,10 +321,4 @@ class SubredditContent(BaseContent):
|
|||||||
data['n_rows'] = len(data['split_title']) + 3
|
data['n_rows'] = len(data['split_title']) + 3
|
||||||
data['offset'] = 0
|
data['offset'] = 0
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def iterate(self, index, step, n_cols):
|
|
||||||
|
|
||||||
while True:
|
|
||||||
yield self.get(index, n_cols)
|
|
||||||
index += step
|
|
||||||
11
rtv/page.py
11
rtv/page.py
@@ -41,10 +41,13 @@ class Navigator(object):
|
|||||||
|
|
||||||
if forward:
|
if forward:
|
||||||
if self.page_index < 0:
|
if self.page_index < 0:
|
||||||
# Special case - advance the page index if less than zero
|
if self._is_valid(0):
|
||||||
self.page_index = 0
|
# Special case - advance the page index if less than zero
|
||||||
self.cursor_index = 0
|
self.page_index = 0
|
||||||
redraw = True
|
self.cursor_index = 0
|
||||||
|
redraw = True
|
||||||
|
else:
|
||||||
|
valid = False
|
||||||
else:
|
else:
|
||||||
self.cursor_index += 1
|
self.cursor_index += 1
|
||||||
if self.cursor_index >= n_windows - 1:
|
if self.cursor_index >= n_windows - 1:
|
||||||
|
|||||||
Reference in New Issue
Block a user