def set_value(name, value):

    term = get_term()

    if name == VALUE_USER_TOKEN:

        file = _get_or_create_netrc_location()

        rc = netrc.netrc(file=file)

        wercker_url = get_value(VALUE_WERCKER_URL)
        url = urlparse(wercker_url)

        if url.hostname in rc.hosts:
            current_settings = rc.hosts[url.hostname]
        else:
            current_settings = (None, None, None)

        if value is not None:
            rc.hosts[url.hostname] = (
                current_settings[0],
                current_settings[1],
                value
            )
        else:
            rc.hosts.pop(url.hostname)

        with open(file, 'w') as fp:
            fp.write(str(rc))
            fp.close()

    elif name == VALUE_USER_NAME:

        file = _get_or_create_netrc_location()

        rc = netrc.netrc(file=file)

        wercker_url = get_value(VALUE_WERCKER_URL)
        url = urlparse(wercker_url)

        if url.hostname in rc.hosts:
            current_settings = rc.hosts[url.hostname]
        else:
            current_settings = (None, None, None)

        if value is not None:
            rc.hosts[url.hostname] = (
                value,
                current_settings[1],
                current_settings[2])
        else:
            rc.hosts.pop(url.hostname)

        with open(file, 'w') as fp:
            fp.write(str(rc))
            fp.close()

    elif name == VALUE_PROJECT_ID:

        path = find_git_root(os.curdir)

        if not path:
            puts(
                term.red("Error:") +
                " Could not find the root repository."
            )
            return

        file = os.path.join(
            path,
            DEFAULT_DOT_WERCKER_NAME
        )

        Config = ConfigParser.ConfigParser()

        if os.path.isfile(file):

            Config.read(file)

        if not 'project' in Config.sections():
            Config.add_section('project')

        fp = open(file, 'w')
        Config.set('project', 'id', value)

        Config.write(fp)

        fp.close()
dataset/ETHPy150Open wercker/wercker-cli/werckercli/config.py/set_value/original