# Path: magnate/market.py
# class CommodityData:
# class Commodity:
# class SystemData:
# class LocationData:
# class Market:
#     def __init__(self, pubpen, commodity_data):
#     def __getattr__(self, key):
#     def __repr__(self):
#     def __init__(self, magnate, location_data, commodity_data):
#     def __getattr__(self, key):
#     def handle_market_info(self):
#     def handle_movement(self, new_location, *args):
#     def recalculate_prices(self):
#     def _calculate_price(self, commodity):
# 
# Path: magnate/ui/urwid/abcwidget.py
# class ABCWidget(urwid.WidgetMeta, ABCMeta):
#     """Combine ABCMeta and Widgetmeta together so that we can have a metaclass with both"""
#     pass
# 
# Path: magnate/ui/urwid/indexed_menu.py
# class IndexedMenuButton(urwid.Button):
#     """A button without decorations"""
#     button_left = urwid.Text("")
#     button_right = urwid.Text("")
# 
# class IndexedMenuEnumerator(MutableMapping):
#     """
#     Generates new indexes for enumerating a menu and associates an index to
#     a vselection.
# 
#     A selection is used by calling code to tell which entry was selected via
#     a keypress
#     """
#     idx_names = [str(c) for c in itertools.chain(
#         range(1, 10),
#         [0],
#         (c for c in punctuation if c not in frozenset('(){}[]<>'))
#     )]
# 
#     def __init__(self):
#         self.association = {}
#         self.idx = 0
# 
#     def set_next(self, selection):
#         """
#         Adds a new selection to the IndexedMenuEnumerator, picking the new key
#         from the list of valid enumerations
# 
#         :arg selection: The value being set
#         :returns: The key that was picked
#         """
#         try:
#             key = self.idx_names[self.idx]
#         except IndexError:
#             raise IndexError('Not enough prefixes to enumerate all list entries')
#         self.idx += 1
#         self.association[key] = selection
#         return key
# 
#     def clear(self):
#         """
#         Clear the mapping
# 
#         In addition to normal dict behaviour, this also resets the next index back to the beginning
#         """
#         super().clear()
#         self.idx = 0
# 
#     def __setitem__(self, name, selection):
#         """Sets a key's value.
# 
#         :arg name: The key
#         :arg selection: The value
# 
#         .. warning:: Unlike dict, this cannot be used to set new keys.  Use
#             :meth:`set_next` instead.
#         """
#         if name not in self.association:
#             raise KeyError('Can only create new keys for an IndexedMenuEnumerator via set_next()')
#         self.association[name] = selection
# 
#     def __getitem__(self, name):
#         return self.association[name]
# 
#     def __delitem__(self, name):
#         del self.association[name]
# 
#     def __iter__(self):
#         return iter(self.association)
# 
#     def __len__(self):
#         return len(self.association)
# 
# 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


from collections import OrderedDict
from abc import abstractmethod
from functools import partial
from ...market import CommodityType
from .abcwidget import ABCWidget
from .indexed_menu import IndexedMenuButton, IndexedMenuEnumerator
from .numbers import format_number
import attr
import urwid
            column.widget_list[idx].set_attr_map({None: 'reversed'})

    def _sync_data_maps(self):
        """
        Make sure the data_map for each column contains the same commodities
        in the same order as the main commodity map
        """
        for column in self.auxiliary_cols:
            new_commodity_map = OrderedDict()
            for commodity in self.commodity_col.data_map:
                new_value = column.data_map.get(commodity, None)
                if column.money:
                    if new_value is None:
                        new_value = 0
                else:
                    if new_value == 0:
                        new_value = None
                new_commodity_map[commodity] = new_value

            column.data_map = new_commodity_map

    def _sync_widget_lists(self):
        """
        Make sure the widget_list for each column contains the same
        commodities in the same order as the main commodity map
        """
        for column in self.auxiliary_cols:
            column.widget_list.clear()  # pylint: disable=no-member
            for commodity, value in column.data_map.items():
                if isinstance(value, int):

# Path: magnate/market.py
# class CommodityData:
# class Commodity:
# class SystemData:
# class LocationData:
# class Market:
#     def __init__(self, pubpen, commodity_data):
#     def __getattr__(self, key):
#     def __repr__(self):
#     def __init__(self, magnate, location_data, commodity_data):
#     def __getattr__(self, key):
#     def handle_market_info(self):
#     def handle_movement(self, new_location, *args):
#     def recalculate_prices(self):
#     def _calculate_price(self, commodity):
# 
# Path: magnate/ui/urwid/abcwidget.py
# class ABCWidget(urwid.WidgetMeta, ABCMeta):
#     """Combine ABCMeta and Widgetmeta together so that we can have a metaclass with both"""
#     pass
# 
# Path: magnate/ui/urwid/indexed_menu.py
# class IndexedMenuButton(urwid.Button):
#     """A button without decorations"""
#     button_left = urwid.Text("")
#     button_right = urwid.Text("")
# 
# class IndexedMenuEnumerator(MutableMapping):
#     """
#     Generates new indexes for enumerating a menu and associates an index to
#     a vselection.
# 
#     A selection is used by calling code to tell which entry was selected via
#     a keypress
#     """
#     idx_names = [str(c) for c in itertools.chain(
#         range(1, 10),
#         [0],
#         (c for c in punctuation if c not in frozenset('(){}[]<>'))
#     )]
# 
#     def __init__(self):
#         self.association = {}
#         self.idx = 0
# 
#     def set_next(self, selection):
#         """
#         Adds a new selection to the IndexedMenuEnumerator, picking the new key
#         from the list of valid enumerations
# 
#         :arg selection: The value being set
#         :returns: The key that was picked
#         """
#         try:
#             key = self.idx_names[self.idx]
#         except IndexError:
#             raise IndexError('Not enough prefixes to enumerate all list entries')
#         self.idx += 1
#         self.association[key] = selection
#         return key
# 
#     def clear(self):
#         """
#         Clear the mapping
# 
#         In addition to normal dict behaviour, this also resets the next index back to the beginning
#         """
#         super().clear()
#         self.idx = 0
# 
#     def __setitem__(self, name, selection):
#         """Sets a key's value.
# 
#         :arg name: The key
#         :arg selection: The value
# 
#         .. warning:: Unlike dict, this cannot be used to set new keys.  Use
#             :meth:`set_next` instead.
#         """
#         if name not in self.association:
#             raise KeyError('Can only create new keys for an IndexedMenuEnumerator via set_next()')
#         self.association[name] = selection
# 
#     def __getitem__(self, name):
#         return self.association[name]
# 
#     def __delitem__(self, name):
#         del self.association[name]
# 
#     def __iter__(self):
#         return iter(self.association)
# 
#     def __len__(self):
#         return len(self.association)
# 
# 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/commodity_catalog.py
from collections import OrderedDict
from abc import abstractmethod
from functools import partial
from ...market import CommodityType
from .abcwidget import ABCWidget
from .indexed_menu import IndexedMenuButton, IndexedMenuEnumerator
from .numbers import format_number
import attr
import urwid

            column.widget_list[idx].set_attr_map({None: 'reversed'})

    def _sync_data_maps(self):
        """
        Make sure the data_map for each column contains the same commodities
        in the same order as the main commodity map
        """
        for column in self.auxiliary_cols:
            new_commodity_map = OrderedDict()
            for commodity in self.commodity_col.data_map:
                new_value = column.data_map.get(commodity, None)
                if column.money:
                    if new_value is None:
                        new_value = 0
                else:
                    if new_value == 0:
                        new_value = None
                new_commodity_map[commodity] = new_value

            column.data_map = new_commodity_map

    def _sync_widget_lists(self):
        """
        Make sure the widget_list for each column contains the same
        commodities in the same order as the main commodity map
        """
        for column in self.auxiliary_cols:
            column.widget_list.clear()  # pylint: disable=no-member
            for commodity, value in column.data_map.items():
                if isinstance(value, int):

                    formatted_number = format_number(value)