# Path: magnate/ui/urwid/numbers.py
# def format_number(number, max_chars=7):
#     """
#     Format a number in a human readable form.  This adds locale-specific separators.
# 
#     If the number is too long, se scientific notation.
# 
#     :kwarg max_chars: The maximum number of characters a number can take on
#         the screen before it is turned into scientific notation.
#     """
#     formatted_number = locale.format('%d', number, grouping=True)
#     if len(formatted_number) > max_chars:
#         formatted_number = '{:.1E}'.format(number)
# 
#     return formatted_number


import urwid
from .numbers import format_number
                                            header7, self.cash_widget,
                                            header8, self.bank_widget,
                                            header9, self.loan_widget])
        info = urwid.ListBox(info_list)
        box = urwid.LineBox(info, tlcorner='─', trcorner='─', lline=' ', rline=None, bline=None)
        super().__init__(box)

        # Primary triggers: These are events that tell us we need to refresh
        # our information
        self.pubpen.subscribe('ship.moved', self.handle_new_location)
        self.pubpen.subscribe('ship.cargo.update', self.handle_cargo_update)
        self.pubpen.subscribe('ship.equip.update', self.handle_ship_update)
        self.pubpen.subscribe('user.cash.update', self.handle_cash_update)
        #self.pubpen.subscribe('user.bank.update')
        #self.pubpen.subscribe('user.loan.update')

        # Secondary triggers: These are responses to requests for information
        self.pubpen.subscribe('ship.info', self.handle_ship_info)
        self.pubpen.subscribe('user.info', self.handle_user_info)

        # Defer populating the initial values until a user has logged in
        self.pubpen.subscribe('user.login_success', self.populate_info)

    @property
    def free_space(self):
        return self._free_space

    @free_space.setter
    def free_space(self, new_value):
        self._free_space = new_value

# Path: magnate/ui/urwid/numbers.py
# def format_number(number, max_chars=7):
#     """
#     Format a number in a human readable form.  This adds locale-specific separators.
# 
#     If the number is too long, se scientific notation.
# 
#     :kwarg max_chars: The maximum number of characters a number can take on
#         the screen before it is turned into scientific notation.
#     """
#     formatted_number = locale.format('%d', number, grouping=True)
#     if len(formatted_number) > max_chars:
#         formatted_number = '{:.1E}'.format(number)
# 
#     return formatted_number


# Path: magnate/ui/urwid/info_win.py
import urwid
from .numbers import format_number

                                            header7, self.cash_widget,
                                            header8, self.bank_widget,
                                            header9, self.loan_widget])
        info = urwid.ListBox(info_list)
        box = urwid.LineBox(info, tlcorner='─', trcorner='─', lline=' ', rline=None, bline=None)
        super().__init__(box)

        # Primary triggers: These are events that tell us we need to refresh
        # our information
        self.pubpen.subscribe('ship.moved', self.handle_new_location)
        self.pubpen.subscribe('ship.cargo.update', self.handle_cargo_update)
        self.pubpen.subscribe('ship.equip.update', self.handle_ship_update)
        self.pubpen.subscribe('user.cash.update', self.handle_cash_update)
        #self.pubpen.subscribe('user.bank.update')
        #self.pubpen.subscribe('user.loan.update')

        # Secondary triggers: These are responses to requests for information
        self.pubpen.subscribe('ship.info', self.handle_ship_info)
        self.pubpen.subscribe('user.info', self.handle_user_info)

        # Defer populating the initial values until a user has logged in
        self.pubpen.subscribe('user.login_success', self.populate_info)

    @property
    def free_space(self):
        return self._free_space

    @free_space.setter
    def free_space(self, new_value):
        self._free_space = new_value

        self.free_space_widget.set_text(' {}'.format(format_number(new_value)))