def print_napps(napps):
        """Print status, name and description."""
        if not napps:
            print('No NApps found.')
            return

        stat_w = 6  # We already know the size of Status col
        name_w = max(len(n[1]) for n in napps)
        desc_w = max(len(n[2]) for n in napps)
        term_w = os.popen('stty size', 'r').read().split()[1]
        remaining = max(0, int(term_w) - stat_w - name_w - 6)
        desc_w = min(desc_w, remaining)
        widths = (stat_w, name_w, desc_w)

        header = '\n{:^%d} | {:^%d} | {:^%d}' % widths
        row = '{:^%d} | {:<%d} | {:<%d}' % widths
        print(header.format('Status', 'NApp ID', 'Description'))
        print('=+='.join('=' * w for w in widths))
        for user, name, desc in napps:
            desc = (desc[:desc_w - 3] + '...') if len(desc) > desc_w else desc
            print(row.format(user, name, desc))

        print('\nStatus: (i)nstalled, (e)nabled\n')
def print_napps ( napps ) : if not napps : print ( 'No NApps found.' ) return stat_w = 6 name_w = max ( len ( n [ 1 ] ) for n in napps ) desc_w = max ( len ( n [ 2 ] ) for n in napps ) term_w = os . popen ( 'stty size' , 'r' ) . read ( ) . split ( ) [ 1 ] remaining = max ( 0 , int ( term_w ) - stat_w - name_w - 6 ) desc_w = min ( desc_w , remaining ) widths = ( stat_w , name_w , desc_w ) header = '\n{:^%d} | {:^%d} | {:^%d}' % widths row = '{:^%d} | {:<%d} | {:<%d}' % widths print ( header . format ( 'Status' , 'NApp ID' , 'Description' ) ) print ( '=+=' . join ( '=' * w for w in widths ) ) for user , name , desc in napps : desc = ( desc [ : desc_w - 3 ] + '...' ) if len ( desc ) > desc_w else desc print ( row . format ( user , name , desc ) ) print ( '\nStatus: (i)nstalled, (e)nabled\n' )
Print status, name and description.