<s> """<STR_LIT>""" <EOL> import collections <EOL> import time <EOL> import os <EOL> from x84 . bbs import getsession , getterminal <EOL> from x84 . bbs import echo , timeago , get_ini <EOL> from x84 . bbs import get_user , list_users <EOL> from common import display_banner , prompt_pager <EOL> here = os . path . dirname ( __file__ ) <EOL> art_file = get_ini ( <EOL> section = '<STR_LIT>' , key = '<STR_LIT>' <EOL> ) or os . path . join ( here , '<STR_LIT>' , '<STR_LIT>' ) <EOL> art_encoding = get_ini ( <EOL> section = '<STR_LIT>' , key = '<STR_LIT>' <EOL> ) or '<STR_LIT>' <EOL> syncterm_font = get_ini ( <EOL> section = '<STR_LIT>' , key = '<STR_LIT>' <EOL> ) or '<STR_LIT>' <EOL> username_max_length = get_ini ( <EOL> section = '<STR_LIT>' , key = '<STR_LIT>' , getter = '<STR_LIT>' <EOL> ) or <NUM_LIT:10> <EOL> location_max_length = get_ini ( <EOL> section = '<STR_LIT>' , key = '<STR_LIT>' , getter = '<STR_LIT>' <EOL> ) or <NUM_LIT> <EOL> def iter_userlist ( ) : <EOL> handles = sorted ( list_users ( ) , key = unicode . lower ) <EOL> timenow = time . time ( ) <EOL> user_record = collections . namedtuple ( '<STR_LIT>' , [ <EOL> '<STR_LIT>' , '<STR_LIT:location>' , '<STR_LIT>' ] ) <EOL> return ( user_record ( handle = user . handle , <EOL> location = user . location , <EOL> timeago = timenow - user . lastcall ) <EOL> for user in ( get_user ( handle ) for handle in handles ) ) <EOL> def main ( ) : <EOL> session , term = getsession ( ) , getterminal ( ) <EOL> session . activity = '<STR_LIT>' <EOL> colors = { '<STR_LIT>' : term . red , <EOL> '<STR_LIT>' : term . green , } <EOL> line_no = display_banner ( filepattern = art_file , encoding = art_encoding ) <EOL> def make_header ( fmt ) : <EOL> return fmt . format ( <EOL> handle = term . bold ( '<STR_LIT>' . ljust ( username_max_length ) ) , <EOL> location = term . bold ( '<STR_LIT:location>' . ljust ( location_max_length ) ) , <EOL> lastcall = term . bold ( '<STR_LIT>' ) . ljust ( <NUM_LIT:8> ) ) <EOL> userlist_fmt = u'<STR_LIT>' <EOL> header = make_header ( userlist_fmt ) <EOL> header_length = term . length ( header ) <EOL> if header_length > term . width : <EOL> userlist_fmt = u'<STR_LIT>' <EOL> header = make_header ( userlist_fmt ) <EOL> header_length = term . length ( header ) <EOL> userlist = [ header ] + [ '<STR_LIT:->' * header_length ] <EOL> for _ur in iter_userlist ( ) : <EOL> location_txt = u'<STR_LIT>' <EOL> if '<STR_LIT:location>' in userlist_fmt : <EOL> location_txt = colors [ '<STR_LIT>' ] ( <EOL> _ur . location . ljust ( location_max_length ) ) <EOL> timeago_txt = timeago ( _ur . timeago ) . ljust ( <NUM_LIT:8> ) <EOL> handle_txt = _ur . handle . ljust ( username_max_length ) <EOL> userlist . append ( userlist_fmt . format ( <EOL> handle = handle_txt , <EOL> location = location_txt , <EOL> lastcall = timeago_txt ) ) <EOL> echo ( u'<STR_LIT:\r\n>' ) <EOL> prompt_pager ( content = userlist , <EOL> line_no = line_no + <NUM_LIT:1> , <EOL> colors = { '<STR_LIT>' : term . red , <EOL> '<STR_LIT>' : term . green , <EOL> } , <EOL> width = <NUM_LIT> , breaker = None ) </s>
