# Path: confduino/boardinstall.py
# def install_board(board_id, board_options, hwpack='arduino', replace_existing=False):
#     """install board in boards.txt.
# 
#     :param board_id: string identifier
#     :param board_options: dict like
#     :param replace_existing: bool
#     :rtype: None
# 
#     """
#     doaction = 0
#     if board_id in boards(hwpack).keys():
#         log.debug('board already exists: %s', board_id)
#         if replace_existing:
#             log.debug('remove board: %s' , board_id)
#             remove_board(board_id)
#             doaction = 1
#     else:
#         doaction = 1
# 
#     if doaction:
#         lines = bunch2properties(board_id, board_options)
#         boards_txt().write_lines([''] + lines, append=1)
# 
# Path: confduino/util.py
# class AutoBunch (Munch):
# 
#     def __getattr__(self, k):
#         '''
#         Bunch is created for missing keys:
# 
#         >>> x=AutoBunch()
#         >>> x.mega.name = 'xy'
#         '''
#         try:
#             return self[k]
#         except KeyError:
#             #            raise AttributeError(k)
#             self[k] = AutoBunch()
#             return self[k]
# 
#     def __setattr__(self, k, v):
#         """Recursive.
# 
#         >>> x=AutoBunch()
#         >>> setattr(x, 'mega.name', 'xy')
# 
#         """
#         k2, _, k3 = k.partition('.')
#         if k3:
#             self.__getattr__(k2).__setattr__(k3, v)
#         else:
#             Munch.__setattr__(self, k, v)


from confduino.boardinstall import install_board
from confduino.util import AutoBunch
from entrypoint2 import entrypoint
    return f + '' + suffix


@entrypoint
def main(
    upload='usbasp',
    core='arduino',
    replace_existing=True,
):
    """install custom boards."""

    def install(mcu, f_cpu, kbyte):
        board = AutoBunch()
        board.name = TEMPL_NAME.format(mcu=mcu,
                                       f_cpu=format_freq(f_cpu),
                                       upload=upload)
        board_id = TEMPL_ID.format(mcu=mcu,
                                   f_cpu=(f_cpu),
                                   upload=upload)

        board.upload.using = upload
        board.upload.maximum_size = kbyte * 1024

        board.build.mcu = mcu
        board.build.f_cpu = str(f_cpu) + 'L'
        board.build.core = core

        # for 1.0
        board.build.variant = 'standard'


# Path: confduino/boardinstall.py
# def install_board(board_id, board_options, hwpack='arduino', replace_existing=False):
#     """install board in boards.txt.
# 
#     :param board_id: string identifier
#     :param board_options: dict like
#     :param replace_existing: bool
#     :rtype: None
# 
#     """
#     doaction = 0
#     if board_id in boards(hwpack).keys():
#         log.debug('board already exists: %s', board_id)
#         if replace_existing:
#             log.debug('remove board: %s' , board_id)
#             remove_board(board_id)
#             doaction = 1
#     else:
#         doaction = 1
# 
#     if doaction:
#         lines = bunch2properties(board_id, board_options)
#         boards_txt().write_lines([''] + lines, append=1)
# 
# Path: confduino/util.py
# class AutoBunch (Munch):
# 
#     def __getattr__(self, k):
#         '''
#         Bunch is created for missing keys:
# 
#         >>> x=AutoBunch()
#         >>> x.mega.name = 'xy'
#         '''
#         try:
#             return self[k]
#         except KeyError:
#             #            raise AttributeError(k)
#             self[k] = AutoBunch()
#             return self[k]
# 
#     def __setattr__(self, k, v):
#         """Recursive.
# 
#         >>> x=AutoBunch()
#         >>> setattr(x, 'mega.name', 'xy')
# 
#         """
#         k2, _, k3 = k.partition('.')
#         if k3:
#             self.__getattr__(k2).__setattr__(k3, v)
#         else:
#             Munch.__setattr__(self, k, v)


# Path: confduino/examples/custom_boards.py
from confduino.boardinstall import install_board
from confduino.util import AutoBunch
from entrypoint2 import entrypoint

    return f + '' + suffix


@entrypoint
def main(
    upload='usbasp',
    core='arduino',
    replace_existing=True,
):
    """install custom boards."""

    def install(mcu, f_cpu, kbyte):
        board = AutoBunch()
        board.name = TEMPL_NAME.format(mcu=mcu,
                                       f_cpu=format_freq(f_cpu),
                                       upload=upload)
        board_id = TEMPL_ID.format(mcu=mcu,
                                   f_cpu=(f_cpu),
                                   upload=upload)

        board.upload.using = upload
        board.upload.maximum_size = kbyte * 1024

        board.build.mcu = mcu
        board.build.f_cpu = str(f_cpu) + 'L'
        board.build.core = core

        # for 1.0
        board.build.variant = 'standard'


        install_board(board_id, board, replace_existing=replace_existing)