# Path: confduino/boardlist.py
# def boards(hwpack='arduino'):
#     """read boards from boards.txt.
# 
#     :param core_package: 'all,'arduino',..
# 
#     """
#     bunch = read_properties(boards_txt(hwpack))
# 
#     bunch_items = list(bunch.items())
# 
#     # remove invalid boards
#     for bid, board in bunch_items:
#         if 'build' not in board.keys() or 'name' not in board.keys():
#             log.debug('invalid board found: %s', bid)
#             del bunch[bid]
# 
#     return bunch
# 
# def board_names(hwpack='arduino'):
#     """return installed board names."""
#     ls = list(boards(hwpack).keys())
#     ls.sort()
#     return ls
# 
# Path: confduino/hwpacklist.py
# def hwpack_names():
#     """return installed hardware package names."""
#     ls = hwpack_dir().listdir()
#     ls = [x.name for x in ls]
#     ls = [x for x in ls if x != 'tools']
#     arduino_included = 'arduino' in ls
#     ls = [x for x in ls if x != 'arduino']
#     ls.sort()
#     if arduino_included:
#         ls = ['arduino'] + ls  # move to 1st pos
#     return ls


from munch import unmunchify
from confduino.boardlist import boards, board_names
from confduino.hwpacklist import hwpack_names
from entrypoint2 import entrypoint
import logging

log = logging.getLogger(__name__)


def mcus():
    """MCU list."""
    ls = []
    for h in hwpack_names():
        for b in board_names(h):
            ls += [mcu(b, h)]
    ls = sorted(list(set(ls)))
    return ls


def mcu(board_id, hwpack_id):
    """"""

# Path: confduino/boardlist.py
# def boards(hwpack='arduino'):
#     """read boards from boards.txt.
# 
#     :param core_package: 'all,'arduino',..
# 
#     """
#     bunch = read_properties(boards_txt(hwpack))
# 
#     bunch_items = list(bunch.items())
# 
#     # remove invalid boards
#     for bid, board in bunch_items:
#         if 'build' not in board.keys() or 'name' not in board.keys():
#             log.debug('invalid board found: %s', bid)
#             del bunch[bid]
# 
#     return bunch
# 
# def board_names(hwpack='arduino'):
#     """return installed board names."""
#     ls = list(boards(hwpack).keys())
#     ls.sort()
#     return ls
# 
# Path: confduino/hwpacklist.py
# def hwpack_names():
#     """return installed hardware package names."""
#     ls = hwpack_dir().listdir()
#     ls = [x.name for x in ls]
#     ls = [x for x in ls if x != 'tools']
#     arduino_included = 'arduino' in ls
#     ls = [x for x in ls if x != 'arduino']
#     ls.sort()
#     if arduino_included:
#         ls = ['arduino'] + ls  # move to 1st pos
#     return ls


# Path: confduino/mculist.py
from munch import unmunchify
from confduino.boardlist import boards, board_names
from confduino.hwpacklist import hwpack_names
from entrypoint2 import entrypoint
import logging


log = logging.getLogger(__name__)


def mcus():
    """MCU list."""
    ls = []
    for h in hwpack_names():
        for b in board_names(h):
            ls += [mcu(b, h)]
    ls = sorted(list(set(ls)))
    return ls


def mcu(board_id, hwpack_id):
    """"""

    board = boards(hwpack=hwpack_id)[board_id]