Example #1
0
def test_2():
    x = AutoBunch()
    x.a.b = 3
    check_keys(x.keys(), ["a"])
    eq_(x["a"]["b"], 3)
    eq_(x.a.b, 3)
    eq_(x["a"].b, 3)
    eq_(x.a["b"], 3)

    lines = bunch2properties("x", x)
Example #2
0
def test_setattr():
    x = AutoBunch()
    setattr(x, "a.b", 3)
    check_keys(x.keys(), ["a"])
    eq_(x["a"]["b"], 3)
    eq_(x.a.b, 3)
    eq_(x["a"].b, 3)
    eq_(x.a["b"], 3)

    lines = bunch2properties("x", x)
Example #3
0
def install_programmer(programmer_id, programmer_options, replace_existing=False):
    """install programmer in programmers.txt.

    :param programmer_id: string identifier
    :param programmer_options: dict like
    :param replace_existing: bool
    :rtype: None

    """
    doaction = 0
    if programmer_id in programmers().keys():
        log.debug('programmer already exists: %s', programmer_id)
        if replace_existing:
            log.debug('remove programmer: %s', programmer_id)
            remove_programmer(programmer_id)
            doaction = 1
    else:
        doaction = 1

    if doaction:
        lines = bunch2properties(programmer_id, programmer_options)
        programmers_txt().write_lines([''] + lines, append=1)
Example #4
0
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)
Example #5
0
def install_programmer(programmer_id,
                       programmer_options,
                       replace_existing=False):
    """install programmer in programmers.txt.

    :param programmer_id: string identifier
    :param programmer_options: dict like
    :param replace_existing: bool
    :rtype: None

    """
    doaction = 0
    if programmer_id in programmers().keys():
        log.debug('programmer already exists: %s', programmer_id)
        if replace_existing:
            log.debug('remove programmer: %s', programmer_id)
            remove_programmer(programmer_id)
            doaction = 1
    else:
        doaction = 1

    if doaction:
        lines = bunch2properties(programmer_id, programmer_options)
        programmers_txt().write_lines([''] + lines, append=1)