<s> from __future__ import unicode_literals <EOL> import curses <EOL> from . page import Page , PageController <EOL> from . content import SubscriptionContent <EOL> from . objects import Color , Navigator , Command <EOL> class SubscriptionController ( PageController ) : <EOL> character_map = { } <EOL> class SubscriptionPage ( Page ) : <EOL> def __init__ ( self , reddit , term , config , oauth ) : <EOL> super ( SubscriptionPage , self ) . __init__ ( reddit , term , config , oauth ) <EOL> self . controller = SubscriptionController ( self , keymap = config . keymap ) <EOL> self . content = SubscriptionContent . from_user ( reddit , term . loader ) <EOL> self . nav = Navigator ( self . content . get ) <EOL> self . subreddit_data = None <EOL> @ SubscriptionController . register ( Command ( '<STR_LIT>' ) ) <EOL> def refresh_content ( self , order = None , name = None ) : <EOL> "<STR_LIT>" <EOL> if order : <EOL> self . term . flash ( ) <EOL> return <EOL> with self . term . loader ( ) : <EOL> self . content = SubscriptionContent . from_user ( self . reddit , <EOL> self . term . loader ) <EOL> if not self . term . loader . exception : <EOL> self . nav = Navigator ( self . content . get ) <EOL> @ SubscriptionController . register ( Command ( '<STR_LIT>' ) ) <EOL> def select_subreddit ( self ) : <EOL> "<STR_LIT>" <EOL> self . subreddit_data = self . content . get ( self . nav . absolute_index ) <EOL> self . active = False <EOL> @ SubscriptionController . register ( Command ( '<STR_LIT>' ) ) <EOL> def close_subscriptions ( self ) : <EOL> "<STR_LIT>" <EOL> self . active = False <EOL> def _draw_banner ( self ) : <EOL> pass <EOL> def _draw_item ( self , win , data , inverted ) : <EOL> n_rows , n_cols = win . getmaxyx ( ) <EOL> n_cols -= <NUM_LIT:1> <EOL> valid_rows = range ( <NUM_LIT:0> , n_rows ) <EOL> offset = <NUM_LIT:0> if not inverted else - ( data [ '<STR_LIT>' ] - n_rows ) <EOL> row = offset <EOL> if row in valid_rows : <EOL> attr = curses . A_BOLD | Color . YELLOW <EOL> self . term . add_line ( win , '<STR_LIT>' . format ( ** data ) , row , <NUM_LIT:1> , attr ) <EOL> row = offset + <NUM_LIT:1> <EOL> for row , text in enumerate ( data [ '<STR_LIT>' ] , start = row ) : <EOL> if row in valid_rows : <EOL> self . term . add_line ( win , text , row , <NUM_LIT:1> ) </s>
