#NEWLINE# def fetch_articles( self , output_progress = False ) : #NEWLINE# #INDENT# spinner = None #NEWLINE# if output_progress : #NEWLINE# #INDENT# spinner = Spinner ( 'Loading articles ' ) #NEWLINE# #UNINDENT# articles_index = [ ] #NEWLINE# last_fetch = self . _configs . get ( 'last_fetch' ) #NEWLINE# offset = 0 #NEWLINE# count = 20 #NEWLINE# while True : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# articles = self . _pocket . retrieve ( state = 'unread' , count = count , offset = offset , since = last_fetch ) #NEWLINE# #UNINDENT# except PocketException as e : #NEWLINE# #INDENT# spinner . finish ( ) #NEWLINE# raise_from ( self . _check_exception ( e ) , e ) #NEWLINE# #UNINDENT# if ( not articles [ 'list' ] ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# articles_index . extend ( self . _get_articles_index ( articles ) ) #NEWLINE# offset += count #NEWLINE# if spinner : #NEWLINE# #INDENT# spinner . next ( ) #NEWLINE# #UNINDENT# #UNINDENT# if spinner : #NEWLINE# #INDENT# spinner . finish ( ) #NEWLINE# #UNINDENT# sort_field = self . _configs . get ( 'sort_field' ) #NEWLINE# if ( not sort_field ) : #NEWLINE# #INDENT# sort_field = 'reading_time' #NEWLINE# #UNINDENT# articles_index = sorted ( output_progress , key = itemgetter ( sort_field ) ) #NEWLINE# self . _storage . write ( articles_index ) #NEWLINE# self . _configs . set ( 'last_fetch' , self . _get_timestamp ( datetime . now ( ) ) ) #NEWLINE# self . _configs . write ( )