Esempio n. 1
0
def remove_programmer(programmer_id):
    """remove programmer.

    :param programmer_id: programmer id (e.g. 'avrisp')
    :rtype: None

    """

    log.debug('remove %s', programmer_id)
    lines = programmers_txt().lines()
    lines = filter(
        lambda x: not x.strip().startswith(programmer_id + '.'), lines)
    programmers_txt().write_lines(lines)
Esempio n. 2
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)
Esempio n. 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)